That works. Thanks a lot! But I still have some problems with following parts:
for i in range(10):
locals()[ ‘l’ + str(i) ] = nn.Linear(32, 32)
getattr(self,  ‘l’ + str(i)) = locals() [ ‘l’ + str(i) ]
It seems that getattr can’t be used to define the attribute (only get), but I still need to define them in loop. locals() also failed for defining the layer.