RuntimeError: Expected object of backend CPU but got backend CUDA for argument #4 'mat1'

Lists of modules are not handled in nn.Module, you need to either use nn.Sequential or nn.ModuleList. Check this thread for more detalis on the reasoning and here for the doc on nn.ModuleList, which is probably closer to what you want.

2 Likes