instance_norm

paddle.nn.functional. instance_norm ( x, running_mean=None, running_var=None, weight=None, bias=None, use_input_stats=True, momentum=0.9, eps=1e-05, data_format='NCHW', name=None ) [source]

It is recommended to use InstanceNorm1D , InstanceNorm2D , InstanceNorm3D to call this method internally.

Parameters
  • x (Tensor) – Input Tensor. It’s data type should be float32, float64.

  • running_mean (Tensor, optional) – running mean. Default None. Obsolete (that is, no longer usable).

  • running_var (Tensor, optional) – running variance. Default None. Obsolete (that is, no longer usable).

  • weight (Tensor, optional) – The weight tensor of instance_norm. Default: None. If its value is None, this parameter will be initialized by one.

  • bias (Tensor, optional) – The bias tensor of instance_norm. Default: None. If its value is None, this parameter will be initialized by zero.

  • eps (float, optional) – A value added to the denominator for numerical stability. Default is 1e-5.

  • momentum (float, optional) – The value used for the moving_mean and moving_var computation. Default: 0.9.

  • use_input_stats (bool, optional) – Default True. Obsolete (that is, no longer usable).

  • data_format (str, optional) – Specify the input data format, may be “NC”, “NCL”, “NCHW” or “NCDHW”. Default “NCHW”.

  • name (str, optional) – Name for the InstanceNorm, default is None. For more information, please refer to Name..

Returns

None.

Examples

>>> import paddle
>>> paddle.seed(2023)
>>> x = paddle.rand((2, 2, 2, 3))
>>> instance_norm_out = paddle.nn.functional.instance_norm(x)

>>> print(instance_norm_out)
Tensor(shape=[2, 2, 2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
[[[[ 1.25768495, -0.18054862, -1.26451230],
   [ 1.42167914, -0.58056390, -0.65373862]],
  [[ 0.95882601,  0.25075224, -0.45947552],
   [ 0.21486834,  0.98283297, -1.94780385]]],
 [[[ 0.40697321,  1.90885782, -0.71117985],
   [-0.76650119,  0.19105314, -1.02920341]],
  [[-1.06926346, -0.18710862, -1.11180890],
   [ 0.74275863, -0.11246002,  1.73788261]]]])