Hello Ereebay!



 Ereebay:

I used pytorch 1.2.0. And I checked the both arguments of F.kl_div() in my version of pytorch, they can be tracked normally.


I can’t test this myself on pytorch 1.x, but looking at the code 3 for kl_div()
(specifically line 86, grad_input_val = -target_val * grad_val;),
I only see the gradient being computed for the first (input, your logits)
argument, and not for the second (target, your label).
(I assume that this code is for the current “stable” pytorch version, so
newer than your 1.2.0.)
Could you post your (short, complete, runnable) test script, together
with its output?  Maybe somebody with a non-archaic copy of pytorch
could help look into this.
Best.
K. Frank