torch.nn.BatchNorm2d的使用举例

参考链接: class torch.nn.BatchNorm2d(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

torch.nn.BatchNorm2d的使用举例_第1张图片

代码实验展示:

Microsoft Windows [版本 10.0.18363.1316]
(c) 2019 Microsoft Corporation。保留所有权利。

C:\Users\chenxuqi>conda activate ssd4pytorch1_2_0

(ssd4pytorch1_2_0) C:\Users\chenxuqi>python
Python 3.7.7 (default, May  6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch.nn as nn
>>> import torch
>>> torch.manual_seed(seed=20200910)
<torch._C.Generator object at 0x0000024B000BC350>
>>>
>>> model = nn.BatchNorm2d(100)
>>> model
BatchNorm2d(100, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
>>>
>>> data_in = torch.randn(20, 100, 35, 45)
>>> data_in.shape
torch.Size([20, 100, 35, 45])
>>>
>>> data_out = model(data_in)
>>> data_out.shape
torch.Size([20, 100, 35, 45])
>>>
>>>

你可能感兴趣的:(torch.nn.BatchNorm2d的使用举例)