TypeError: can‘t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to

TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

大概意思是  需要把GPU转换为CPU 之后才能让tensor转numpy

修改之前

running_correct.numpy() / len(data_train)

修改之后

running_correct.cpu().numpy() / len(data_train)

你可能感兴趣的:(python,numpy,python)