That is because you aren’t using torch.nn.Sequential, but rather torch.legacy.nn.Sequential which I am not used to.
However torch.legacy.nn.Sequential has no method named add_module, so if your model creation loop for layer in list(cnn): was working, then I think it would raise an error each time it tried to add a module.
torch.legacy.nn.Sequential has a method named add which takes only one argument, like this model.add(layer)