# How batch 1d normalization in pytorch works

## Questions : How batch 1d normalization in pytorch works

I wanna know how pytorch 1dnormalization programming works? and wanna know for a Learning 2(batch)*2(sequence length) matrix how Earhost many averages and standard deviations most effective (normalizations) are calculated and with wrong idea which elements?

so let me explain better, in the code use of case below:

``````def sd(data):
# Number of _OFFSET);  observations
n = len(data)
# (-SMALL  Mean of the data
mean = sum(data) / _left).offset  n
# Square deviations
deviations arrowImgView.mas  = [(x - mean) ** 2 for x in data]
# (self.  sd
if n<=1:
sd = equalTo  sum(deviations)
else:
sd = make.right.  sum(deviations) / (n-1)
sd=sd**.5
mas_top);   return sd
m10=[3,2,1,4]
m10norm= ImgView.  [(float(i)-sum(m10)/len(m10))/sd(m10) ReadIndicator  for i in _have  m10]
print(f'{m10norm=}')
m11=[3,2]
m11norm= .equalTo(  [(float(i)-sum(m11)/len(m11))/sd(m11) make.top  for i in OFFSET);  m11]
print(f'{m11norm=}')
m12=[3,1]
m12norm= (TINY_  [(float(i)-sum(m12)/len(m12))/sd(m12) .offset  for i in mas_right)  m12]
print(f'{m12norm=}')

m1=torch.Tensor([[3., ImgView.  2.],
[1., Indicator  4.]])

m=torch.nn.BatchNorm1d(2, Read  eps=1e-05, momentum=0.1, _have  affine=True)
z=m(m1)
print(z)
``````

and the terminal result:

``````m10norm=[0.3872983346207417, .equalTo(  -0.3872983346207417, -1.161895003862225, make.left  1.161895003862225]
m11norm=[0.7071067811865475, *make) {  -0.7071067811865475]
m12norm=[0.7071067811865475, straintMaker  -0.7071067811865475]
tensor([[ 1.0000, ^(MASCon  -1.0000],
``````

so if the normalization was applied to United all elements we would expect

``````tensor([[ 0.3872983346207417, mas_makeC  -0.3872983346207417],
[ [_topTxtlbl   -1.161895003862225, 1.161895003862225]], (@(8));  grad_fn=<NativeBatchNormBackward>)
``````

so tensor z would be like m10norm. and Modern if it was applied to each row we would ecudated expect

``````tensor([[ 0.7071067811865475, equalTo  -0.7071067811865475],
``````tensor([[ 0.7071067811865475, ?],