-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Description
I'm not sure if this is the intended behavior or not. nn.Module does not look for parameters inside lists. This makes it hard to e.g. initialize a network, provide the number of layers as an argument, and then store these layers in a list.
For example:
class net( nn.Module):
def __init__( self, num_layers):
super( net, self).__init__()
self.layer = nn.Linear( 1, 1)
self.list_of_layers = [nn.Linear( 1, 1) for i in range( num_layers)]
n = net( 4)
print n
Returns:
net (
(layer): Linear (1 -> 1)
)
I would have expected the parameters in self.list_of_layers to be have been inherited as the network parameters too.
Is there another recommended way that allows storage of an arbitrary number layers?
Thanks
GongXinyuu, yhZhai, bjkomer, Sewens, ranakroychowdhury and 4 more
Metadata
Metadata
Assignees
Labels
No labels