rescale#

torchdyno.models.initializers.rescale(tensor, method='spectral', value=0.999)[source]#

Rescale a matrix in-place. Rescaling can be done according to the spectral radius, spectral norm, matrix norm, or linear scaling.

Parameters:
  • shape (torch.Size) – shape of the tensor.

  • method (Literal["spectral", "singular", "norm", "linear"]) – rescaling method.

  • value (float) – scaling value.

  • tensor (Tensor)

Returns:

initialized tensor.

Return type:

torch.Tensor