Initlzie multiple instance of a network?

I’m wonder how one could be able to do something like this in pytroch:

for example I want to initalize 64 copies of nn.Conv.2d, I tried to call a for loop and store the network like this:

self. conv_array = []
for i in range (64):
         self. conv_array.append(nn.Conv2d(1, 16, stride=2, kernel_size = 2))

This apparently doesn’t work after I print out the network after initialization as the layers wont show up.

Use nn.ModuleList instead of a Python list to register these modules properly.

1 Like

Thank you, thank works!