我想通过编程找到输入层的大小。
如果我的第一层 fc1
fc1
假设您的模型名为 model ,这将给出 fc1 图层:
model
model.fc1.in_features
这在 .forward() 方法:
.forward()
def forward(self, x): x = x.view(-1, self.fc1.in_features) # resize the input to match the input layer ...