Runtimeerror: expected object of type Variable[torch.LongTensor] but found type Variable[torch.ByteTensor] for argument #1 'target'

pytorch 0.4 is ok! but at pytorch 0.3, i get this error!
hello guys, Does anyone know why? very thanks for reply!!

target has to be long type, maybe target = target.long() will help

thanks for your reply. I wirte my code in early version, but new version of pytorch cannot use. i had try your advice , but it is not work . so I change to the old version of pythorch.