ptrblck:

What’s your use case that you need these None objects in an nn.ModuleList ?


This is not my defined Arch, this arch is Microsoft HRNet 1.
But if you look in his code they are using it to create a new list:
y_list = self.stage2(x_list)

        x_list = []
        for i in range(self.transition2):
            if self.transition2[i] is not None:
                x_list.append(self.transition2[i](y_list[-1]))
            else:
                x_list.append(y_list[i])

self.transition2 is the module list containing None objects
With you workaround C should change is not None with not is isinstance(layer, nn.Identity())
I am going to try your work-around and let you know!