My original model as below:
class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.encoder = Encoder()
        self.decoder = Decoder()

    def forward(self, x):
        x = self.encoder(x)
        x = F.dropout(x, p = 0.2)
        x = self.decoder(x)
        return x

Note that the encoder and decoder consist of multiple modules, respectively.
After saving it and loading it, I want to make the new model by removing the decoder part and adding the classifier.
net = torch.load('net.pth')
class classifier(nn.Module):
    super(classifier, self),__init__()
    self.encoder = nn.Sequential(*list(net.encoder.children()))
    self.fc = nn.Linear(enc_dim, num_class)

    def forward(self, x):
        x = self.encoder(x)
        x = F.dropout(x,p = 0.5)
        x = self.fc(x)
        x = F.log_softmax(x)
        return x

When I execute the script, I got the following error
THCudaCheck FAIL file=torch/csrc/cuda/Module.cpp line=80 error=10 : invalid device ordinal
Can you please tell me how I can solve this error ?
Also, when I use DataParallel, I think
nn.Sequential(*list(ae_net.encoder.children())) 

needs to be modified as like
nn.Sequential(*list(ae_net.module.encoder.children()))

Is it right ?