出错位置:
train_label_batch = torch.from_numpy(train_label_batch)
解决办法:将数据类型转换成FloatTensor即可,如下,加一行代码Tensor.type(torch.FloatTensor)
train_label_batch = torch.from_numpy(train_label_batch)
train_label_batch = train_label_batch.type(torch.FloatTensor) # 转Float
train_label_batch = train_label_batch.cuda() # 转cuda