Rescale each sub-tensor along dim whose p-norm exceeds maxnorm.
Parameters
inputTensorFloating-point or complex tensor with at least 2 dimensions.
pfloatPower for the norm calculation (must be positive).
dimintDimension to slice over in order to obtain the sub-tensors.
maxnormfloatMaximum allowed norm for each sub-tensor (must be non-negative).
Returns
TensorRenormalized tensor of the same shape and dtype as input.
Examples
>>> import lucid
>>> x = lucid.tensor([[3.0, 4.0], [0.3, 0.4]])
>>> lucid.renorm(x, p=2.0, dim=0, maxnorm=1.0)
tensor([[0.6, 0.8], [0.3, 0.4]])