How to train two modules with two different loss in one train_step alternately? #20295
Kami-chanw
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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
toFalse
and process backward manually, but the gradients are alwaysNone
(I printed gradients withprint(param.grad)
). Besides,when I train inddp
, I gotwhen I train in
deepspeed_stage_2_offload
, I gotThis might indicate that the
optimizer.step()
is skipped due to empty gradients.I configure optimizer with following code:
In my train step:
Please help me!!
Beta Was this translation helpful? Give feedback.
All reactions