假设您的模型被称为model
,这将给出该层的输入特征的数量fc1
:
model.fc1.in_features
Run Code Online (Sandbox Code Playgroud)
这在.forward()
方法内部很有用:
def forward(self, x):
x = x.view(-1, self.fc1.in_features) # resize the input to match the input layer
...
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4618 次 |
最近记录: |