小编har*_*hit的帖子

CNN pytorch:如何选择参数并在层之间流动

我对 CNN 很陌生,一直在关注以下代码。我无法理解我们如何以及为什么选择 Conv2d() 和 nn.Linear () 的每个参数,因为它们是输出、过滤器、通道、权重、填充和步幅。我确实理解每个的含义。有人可以非常简洁地解释每一层的流程吗?(输入图片尺寸为 32*32*3)

import torch.nn as nn
import torch.nn.functional as F

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(3, 16, 3, padding=1)
        self.conv2 = nn.Conv2d(16, 32, 3, padding=1)
        self.conv3 = nn.Conv2d(32, 64, 3, padding=1)
        self.pool = nn.MaxPool2d(2, 2)
        self.fc1 = nn.Linear(64 * 4 * 4, 500)
        self.fc2 = nn.Linear(500, 10)
        self.dropout = nn.Dropout(0.25)

    def forward(self, x):
        x = self.pool(F.relu(self.conv1(x)))
        x = self.pool(F.relu(self.conv2(x)))
        x = self.pool(F.relu(self.conv3(x)))
        x = x.view(-1, 64 * 4 * 4) …
Run Code Online (Sandbox Code Playgroud)

python neural-network deep-learning conv-neural-network pytorch

1
推荐指数
1
解决办法
435
查看次数