I am working on someone’s code in torch 0.3.
I want to count number of padding so I wrote:
ys = valid_decoder_inputs[1:,:].view(-1) #true target not_padding = ys.ne(PAD_IDX) no_not_padding = not_padding.sum().item()
However torch 0.3 doesn’t support item(). Can you help of how to write this line of code in torch 0.3?