测试代码:
import torch
import torch.nn as nn m = nn.BatchNorm2d(2,affine=True) #权重w和偏重将被使用 input = torch.randn(1,2,3,4) output = m(input) print("输入图片:") print(input) print("
这篇博客主要通过测试代码展示了在PyTorch中如何使用BatchNorm2d进行数据归一化。内容提到了归一化的计算公式,并特别指出torch计算方差时不使用Bessel's correction,提醒读者在自定义方差计算时需要注意。
测试代码:
import torch
import torch.nn as nn m = nn.BatchNorm2d(2,affine=True) #权重w和偏重将被使用 input = torch.randn(1,2,3,4) output = m(input) print("输入图片:") print(input) print("
1092
1443

被折叠的 条评论
为什么被折叠?