torch.renorm
- torch.renorm(input, p, dim, maxnorm, *, out=None) → Tensor
Returns a tensor where each sub-tensor of
along dimension is normalized such that the -norm of the sub-tensor is lower than the value
Returns a tensor where each sub-tensor of along dimension
is normalized such that the -norm of the sub-tensor is lower
than the value
dimmaxnormExample:
>>> x = torch.ones(3, 3)
>>> x[1].fill_(2)
tensor([ 2., 2., 2.])
>>> x[2].fill_(3)
tensor([ 3., 3., 3.])
>>> x
tensor([[ 1., 1., 1.],
[ 2., 2., 2.],
[ 3., 3., 3.]])
>>> torch.renorm(x, 1, 0, 5)
tensor([[ 1.0000, 1.0000, 1.0000],
[ 1.6667, 1.6667, 1.6667],
[ 1.6667, 1.6667, 1.6667]])