Initialization of a custom block

Putting this here for reference: see also #10101, as I just found out the elements of gluon.nn.Sequential/HybridSequential can be accesed as list elements. That is Sequential/HybridSequantial can be used also as containers without their forward pass. So instead of the list encapsulation that doesn’t work:

self.convs = []
for i in range(5):
    self.convs += [gluon.nn.Conv2D(...)] # Add parameters of choice

def forward(self, input):
    out = self.convs[0](input)
    for i in range(1,5):
       out = self.convs[i](out)

you can use:

self.convs = gluon.nn.Sequential()
for i in range(5):
    self.convs.add(gluon.nn.Conv2D(...)) 

def forward(self, input):
    out = self.convs[0](input)
    # The order of accessing the list elements can be arbitrary
    for i in range(1,5):
       out = self.convs[i](out)

Cheers