trainy = trainy.type(torch.FloatTensor)


完美解决问题