RuntimeError: Found dtype Double but expected Float”
I made a mistake in finding the loss function,
resolvent:
target.float()
a=np.array([[1,2],[3,4]])
b=np.array([[2,3],[4,4]])
loss_fn = torch.nn.MSELoss(reduce=True, size_average=True)
input = torch.autograd.Variable(torch.from_numpy(a))
target = torch.autograd.Variable(torch.from_numpy(b))
loss = loss_fn(input.float(), target.float())
print(loss)
Read More:
- RuntimeError: expected scalar type Double but found Float
- [Solved] RuntimeError: Expected object of scalar type Float but got scalar type Double for argument #2 ‘mat1‘
- Solve the runtimeerror in RNN: expected scalar type long but found float error
- How to Fix TypeError: Cannot cast array data from dtype(‘float64‘) to dtype(‘<U32‘)….
- Successfully solved the problem of “runtimee” in RESNET dataset classification rror:expected scalar type Long but found Float”
- Keras: Cannot convert ‘auto‘ to EagerTensor of dtype float
- Expected STR instance, float found
- Expected indentation of 6 spaces but found 10
- error Expected indentation of 2 spaces but found 8
- Python: How to Fix “Ord() expected string of length 1, but int found”
- An error was reported on the command line of Vue when it first wrote a small project: expected indentation of 4 spaces but found 6
- Python learning notes (5) — cross entropy error runtimeerror: 1D target tensor expected, multi target not supported
- Invalid operands to binary expression (‘double’ and ‘double’)
- How to Fix “junit.framework.Comparison Failure Expected: but was”
- [solved] runtimeerror: module compiled against API version 0xc but this version of numpy is 0xb
- Type error: sequence item 0: expected STR instance, int found
- RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
- Pychar appears“ PEP:8 expected 2 blank lines ,found 1″
- Warning when using numpy: runtimewarning: numpy.dtype size changed, may indicate binary incompatibility
- The reason and solution of the error of join function: sequence item 0: expected STR instance, int found