Multiple input network Training

Hi all.

I have created a network with 2 inputs to pass to forward, which are then concatenated later to be fed into another network.

def forward(self, latent, image):
    # latent, image = input_dict["latent"], input_dict["image"]
    x1 = self.net1(latent)
    print(x1.size())
    x2 = self.net2(image)
    print(x2.size())
    x = torch.cat([x1, x2], 1)
    return self.merge(x)

After passing it to torchsummary, it is able to compile(?) the network with given inputs.

summary(netD, [(1024,1,1), (3,64,64)])

However, I have tried various methods to pass on 2 torch.Tensors to the network for feedfoward but they all throw errors.

dlXGenerated = netG(dlZ, LR)

Can anyone point me to the correct way of passing 2 tensors to a network?


This question may help you.

Ah, thanks for the head up.

It looks like my problem was related to multi-gpu process.
Having commented out the DataParallel comand solves the problem for now.

1 Like