The reason for this problem may be that the data type of tensor is wrong, it may be the wrong type of input X in the backpropagation, or the wrong data type in the training and testing process. If it is the backpropagation process, it depends on which layer of neural network has the problem, and add x = x.to (torch. Float32) in front of which layer, For example, this problem occurs in the first layer of neural network. For example, this problem occurs in the first layer of convolution. The solution is as follows:

If this problem occurs in the training or test model, the solution is as follows:

It is also possible that the type of labels is wrong during training or testing. The solutions are as follows:

### Read More:

- [Solved] Runtime error: expected scalar type Float but found Double
- [Solved] RuntimeError: expected scalar type Long but found Float
- Pytorch Error: RuntimeError: value cannot be converted to type float without overflow: (0.00655336,-0.00
- How to Solve RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu
- Autograd error in Python: runtimeerror: grad can be implicitly created only for scalar outputs
- [Solved] pytorch loss.backward() Error: RuntimeError: Function AddBackward0 returned an invalid gradient at index 1…
- [Solved] RuntimeError: scatter(): Expected dtype int64 for index
- [Solved] RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the
- can‘t multiply sequence by non-int of type ‘numpy.float64‘
- Pytorch ValueError: Expected more than 1 value per channel when training, got input size [1, 768
- [Solved] torchsummary Error: RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.F
- [Pytorch Error Solution] Pytorch distributed RuntimeError: Address already in use
- Python RuntimeError: Expected 4-dimensional input for 4-dimensional weight [32, 1, 5, 5]
- pytorch: RuntimeError CUDA error device-side assert triggered
- [Solved] Pytorch Error: RuntimeError: Error(s) in loading state_dict for Network: size mismatch
- [Solved] RuntimeError : PyTorch was compiled without NumPy support
- [Solved] RuntimeError: gather(): Expected dtype int64 for index
- [Solved] PyTorch Caught RuntimeError in DataLoader worker process 0和invalid argument 0: Sizes of tensors mus
- [Solved] Pytorch error: RuntimeError: one of the variables needed for gradient computation
- [Solved] bushi RuntimeError: version_ ＜= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at /pytorch/caffe2/s