Relative Content

Tag Archive for artificial-intelligencepytorch-lightning

How to train two modules with two different loss in one train_step alternately?

I add two new modules to a large multimodal model. Now, I want to train module A with MSE loss and train module B with CrossEntropy. I’ve tried to set automatic_optimization to False and process backward manually, but the gradients are always None(I printed gradients with print(param.grad)). Besides,when I train in ddp, I got