Tensor
batchnorm

Tensor.batchnorm()

Return the batch normalization of the input tensor.

Usage

from tinygrad.tensor import Tensor
 
a1 = Tensor([
    [[[1, 2], [3, 4]], [[5, 6], [7, 8]]],
    [[[9, 10], [11, 12]], [[13, 14], [15, 16]]]
])
mean_data = Tensor([2.5, 7.5])
invstd_data = Tensor([0.1, 0.2])
 
tensor = a1.batchnorm(None, None, mean_data, invstd_data)
 
print(tensor.numpy())

Return value

[[[[-0.15       -0.05      ]
   [ 0.05        0.15      ]]
 
  [[-0.5        -0.3       ]
   [-0.1         0.1       ]]]
 
 
 [[[ 0.65000004  0.75      ]
   [ 0.85        0.95      ]]
 
  [[ 1.1         1.3000001 ]
   [ 1.5         1.7       ]]]]
;