add_module() missing 1 required positional argument: 'module'

I use the same file in two Google colab, ones can run, but another get a TypeError, which is 'add_module() missing 1 required positional argument: ‘module’.
The following code contains the add_module()

# self.straight.add_module(nn.BatchNorm1d(num_features=out_channel))
self.straight.add_module(nn.ReLU())

length = duration - sum(kernels) + len(kernels)  # 卷积结束后作池差
self.straight.add_module(prefix+"Pooling",
                                 nn.MaxPool1d(kernel_size=length))

.add_module expects a name and module as the arguments. Could you add the name for the relu module and try it again?

1 Like

Thanks, after adding the name, it works!