Is it considered bad practice to add modules to a custom pytorch nn.Module
using self.add_module()
? All of the documentation seems to assign the layers to properties, then access them in the forward()
method.
For example:
class ConvLayer(nn.Module):
def __init__(self):
self.add_module('conv',nn.Conv2d(...))
self.add_module('bn',nn.BatchNorm2d(...))