赞
踩
CIFAR10
神经网络
卷积层Conv公式
Hin=32 Hout=32 padding=未知 dilation=1 kernel_size=5 stride=1
32 = (32 + 2 × padding - 1 × (5 - 1) - 1) / 1 + 1 得padding = 2
具体代码:
- import torch
- from torch import nn
- from torch.utils.tensorboard import SummaryWriter
-
- class TestSeq(nn.Module):
- def __init__(self):
- super(TestSeq, self).__init__()
- self.model = nn.Sequential(
- nn.Conv2d(3, 32, 5, padding=2),
- nn.MaxPool2d(2),
- nn.Conv2d(32, 32, 5, padding=2),
- nn.MaxPool2d(2),
- nn.Conv2d(32, 64, 5, padding=2),
- nn.MaxPool2d(2),
- nn.Flatten(),
- nn.Linear(1024, 64),
- nn.Linear(64, 10)
- )
-
- def forward(self, input):
- output = self.model(input)
- return output
-
-
- ts = TestSeq()
- print(ts)
- input_data = torch.ones((64, 3, 32, 32))
- output = ts(input_data)
- print(output.shape)
-
- writer = SummaryWriter("logs")
- writer.add_graph(ts, input_data)
- writer.close()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。