Prediction related with two model

Hello everyone,

I have a question about my program, I make two nets, one is netaudio and the other is netvideo, the prediction is related with these two nets. I’m not sure what should I do when I calculate the prediction.
Should I do:

audioweight=Variable(netaudio(audio),requires_grad=True)
videoweight=Variable(netvideo(video),requires_grad=True)
prediction=(audioweight.mul(audio)+videoweight.mul(video)).cuda()

or should I just use:

prediction=(netaudio(audio).mul(audio)+netvideo(video).mul(video)).cuda()

Thank you very much,
Best regards
Wentao

Variables are deprecated and you don’t longer need them.
Audioweight and videoweight should be backpropagable as they are network’s output

1 Like

One more question, for two networks, should I also make two optimizers and training these networks like this?:

loss.backward()

optimizeraudio.step()

optimizervideo.step()

Hi, it’s not really necessary. You can create a new nn.Module which contains both and use a single optimizer our you can feed both models into a single one

1 Like