Hi there,
I have a custom module that creates several layers. All of the tutorials show the layers being added as attributes during __init__().
I like the idea of adding them as modules usint the add_modules() method instead (it seems more declarative considering these are sequential models).
Is this considered bad? and if so, why?
For example:
#this class has the modules added with add_module
class UpsampleLayer(nn.Module):
    def __init__(self, scale):
        super(UpsampleLayer,self).__init__()
        upsample = nn.Upsample(scale_factor = scale, mode = "nearest")
        self.add_module("upsample", upsample)

 #this class does not
class UpsampleLayer(nn.Module):
    def __init__(self,scale):
        super(UpsampleLayer,self).__init__()
        self.upsample = nn.Upsample(scale_factor = scale, mode = "nearest")

    def forward(self,x)
        return self.upsample(x)`