这是代码
import torch
import torch.nn as nn
x = torch.Tensor([[1, 2, 3], [1, 2, 3]])
print(x)
batchnorm = nn.BatchNorm1d(3, eps=0, momentum=0)
print(batchnorm(x))
这是打印的内容
tensor([[1., 2., 3.],
[1., 2., 3.]])
tensor([[0., 0., 0.],
[0., 0., 0.]], grad_fn=<NativeBatchNormBackward>)
我期待的是以下内容:
使用手工计算,让, 然后和,所以最终输出看起来像
所以,我期望批处理规范的输出是
tensor([[-1., 0., 1.],
[-1., 0., 1.]])
有人可以解释我哪里出错了吗?