torch_renorm: Renorm

View source: R/gen-namespace.R

torch_renormR Documentation

Renorm

Description

Renorm

Usage

torch_renorm(self, p, dim, maxnorm)

Arguments

self

(Tensor) the input tensor.

p

(float) the power for the norm computation

dim

(int) the dimension to slice over to get the sub-tensors

maxnorm

(float) the maximum norm to keep each sub-tensor under

renorm(input, p, dim, maxnorm, out=NULL) -> Tensor

Returns a tensor where each sub-tensor of input along dimension dim is normalized such that the p-norm of the sub-tensor is lower than the value maxnorm

Note

If the norm of a row is lower than maxnorm, the row is unchanged

Examples

if (torch_is_installed()) {
x = torch_ones(c(3, 3))
x[2,]$fill_(2)
x[3,]$fill_(3)
x
torch_renorm(x, 1, 1, 5)
}

torch documentation built on May 29, 2024, 9:54 a.m.