首页 > 解决方案 > Pytorch 神经网络,理解全连接层

问题描述

强文本

def __init__(self):
        super(Net, self).__init__()
        # 1 input image channel, 6 output channels, 3x3 square convolution
        # kernel
        self.conv1 = nn.Conv2d(1, 6, 3)
        self.conv2 = nn.Conv2d(6, 16, 3)
        # an affine operation: y = Wx + b
        self.fc1 = nn.Linear(16 * 6 * 6, 120)  # 6*6 from image dimension
        self.fc2 = nn.Linear(120, 84)
        self.fc3 = nn.Linear(84, 10)

从上面 PyTorch 神经网络教程的图像和代码,我可以理解卷积的维度。'nn.Linear' 的输出维度是如何确定的?另外,为什么我们需要三个全连接层?

任何帮助将不胜感激。TIA

标签: pythonpytorch

解决方案


推荐阅读