torch_norm | R Documentation |
Norm
torch_norm(self, p = 2L, dim, keepdim = FALSE, dtype)
self |
(Tensor) the input tensor |
p |
(int, float, inf, -inf, 'fro', 'nuc', optional) the order of norm. Default: |
dim |
(int, 2-tuple of ints, 2-list of ints, optional) If it is an int, vector norm will be calculated, if it is 2-tuple of ints, matrix norm will be calculated. If the value is NULL, matrix norm will be calculated when the input tensor only has two dimensions, vector norm will be calculated when the input tensor only has one dimension. If the input tensor has more than two dimensions, the vector norm will be applied to last dimension. |
keepdim |
(bool, optional) whether the output tensors have |
dtype |
( |
Returns the matrix norm or vector norm of a given tensor.
if (torch_is_installed()) {
a <- torch_arange(1, 9, dtype = torch_float())
b <- a$reshape(list(3, 3))
torch_norm(a)
torch_norm(b)
torch_norm(a, Inf)
torch_norm(b, Inf)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.