【PyTorch】RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor)

created at 08-12-2021 views: 38

error message

RuntimeError: Input type (torch.FloatTensor) and weight type 
(torch.cuda.FloatTensor) should be the same or input should 
be a MKLDNN tensor and weight is a dense tensor

reason for the error

Some of the tensors involved in the calculation in the network are on CPU, and some are on GPU, which are determined according to the error message. 

The above error message indicates that the input data tensor is stored in CPU, and you can modify it after careful searching.

created at:08-12-2021
edited at: 08-12-2021: