报错AttributeError: ‘torch.dtype‘ object has no attribute ‘type‘

AttributeError: ‘torch.dtype’ object has no attribute ‘type’

insert image description here
np.mean() can be changed to torch.mean(torch.stack(my_list))

loss is a tensor.
np.mean() can input list or array
. torch.mean() must input tensor, and the final result is also tensor.
torch.stack() stacks data along a certain dimension
, so np.mean() will report an error

Guess you like

Origin blog.csdn.net/qq_31460605/article/details/103709896