Pytorch, Unable to get repr for 
I'm implementing some RL in PyTorch and had to write my own mse_loss function (which I found on Stackoverflow ;) ).
The loss function is:

def mse_loss(input_, target_):    
    return torch.sum(
        (input_ - target_) * (input_ - target_)) / input_.data.nelement()


Now, in my training loop, the first input is something like:

tensor([-1.7610e+10]), tensor([-6.5097e+10])




With this input I'll get the error:

Unable to get repr for &lt;class 'torch.Tensor'&gt;


Computing a = (input_ - target_) works fine, while b = a * a respectively b = torch.pow(a, 2) will fail with the error metioned above.

Does anyone know a fix for this?

Thanks a lot!

Update:
I just tried using torch.nn.functional.mse_loss which will result in the same error..

I had the same error,when I use the below code

criterion = torch.nn.CrossEntropyLoss().cuda()
output=output.cuda()
target=target.cuda()
loss=criterion(output, target)


but I finally found my wrong：output is like tensor([[0.5746,0.4254]]) and target is like tensor([2]),the number 2 is out of indice of output

when I not use GPU,this error message is:

RuntimeError: Assertion `cur_target &gt;= 0 &amp;&amp; cur_target &lt; n_classes' failed.  at /opt/conda/conda-bld/pytorch-nightly_1547458468907/work/aten/src/THNN/generic/ClassNLLCriterion.c:93

