I wanna know is there a way to set names for layers (just like Keras does), thank you.
If you would like to use nn.Sequential
, you can use names with an OrderedDict
.
Have a look at the Sequential example.
Also, if you would like to write your own nn.Module
, it’s pretty straightforward:
class MyModel(nn.Module):
def __init__(self):
super(MyModule, self).__init__()
self.fc1 = nn.Linear(10, 1)
def forward(self, x):
return F.sigmoid(self.fc1(x))
model = MyModel()
model.fc1
1 Like