pytorch 构建神经网络
class Net(nn.Module):
def __init__(self):
super(Net,self).__init__()
#定义第一层卷积层 输入维度 1 输出维度 6 卷积核 3*3
self.conv1 = nn.Conv2d(1,6,3)
#定义第二层卷积层 输入维度6 输出维度 16 卷积核 3*3
self.conv2 = nn.Conv2d(6,16,3)
#定义三层全连接层
self.fc1 = nn.Linear(16 * 6 * 6,120)
self.fc2 = nn.Linear(120,84)
self.fc3 = nn.Linear(84,10)
无报错
self.fc1 = nn.Linear(16 * 6 * 6,120)
self.fc1 = nn.Linear(16 * 6 * 6,120) 中 1666 参数怎么得来的,我知道16是卷积层的输出,而不知道6*6怎么来的
建议打印出 输入的shape ,它是一个tensor,包含[batchsize,channel,H,W],66就是 HW。