modelzoo.common.pytorch.model_utils.weight_initializers.variance_scaling_#

modelzoo.common.pytorch.model_utils.weight_initializers.variance_scaling_(tensor, scale=1.0, mode='fan_in', distribution='truncated_normal')[source]#

Adapted from TensorFlow’s initializations https://www.tensorflow.org/api_docs/python/tf/keras/initializers/VarianceScaling

Fills the input Tensor with values given scale, mode and distribution.

Parameters
  • tensor (torch.Tensor) – an n-dimensional torch.Tensor

  • scale (float) – scaling factor (positive float)

  • mode (str) – mode of weight initialization. Defaults to fan_in

  • distribution (str) – distributino to initialize tensors with. Defaults to truncated_normal

Examples

>>> w = torch.empty(3, 3)
>>> variance_scaling_(w)