Hi, albanD:
Thanks for your reply. I followed your instruction and it works! but I didn’t understand what does the sentence “Also, since you set to 0 all the values that should be to 0 at the end of your function, I think it will be more efficient to apply a full softmax instead of the for loop.” mean? Do you mean I could directly apply nn.Softmax() to get what I want after I multiply raw by one_hots?
Finally, thank you again for your kind help.