I had a problem like this and solved this with change tensors to double type.
tensor.Tensor([...]).double()
or
tensor.Tensor([...]).type(torch.DoubleTensor)
or you can set default tensor type:
torch.set_default_tensor_type('torch.DoubleTensor')

Your implementation will be slower, but ,i hope,  will work