AttributeError: 'torch.dtype' object has no attribute 'type'

Hi all,
I’ve run my code and I got the Error AttributeError: 'torch.dtype' object has no attribute 'type'. Through this following picture, I think np.mean can’t run on a list of tensor and that cause of my crashed code.
Could anyone tell me how to tackle this error?

The easiest might be to provide use torch.stack(batch_losses).mean().item() or so to make a PyTorch tensor from a list of tensors and take the mean. .item() converts to a Python number.

Best regards

Thomas

1 Like

I appreciate you! My problem was solved.