I want to log the loss of the train using the tensorboard in pytorch. I got an error there.
AttributeError: 'Tensor' object has no attribute 'items'
I want to solve this error and check the log using tensorboard. Here I show my code.
l_mse = mseloss(img,decoder_out)
writer.add_scalars("MSE",l_mse,n_iter)
then I have error blow.
Traceback (most recent call last):
File "main.py", line 39, in <module>
main()
File "main.py", line 22, in main
solover.train(dataloader)
File "path to my file", line 239, in train
writer.add_scalars("MSE",l_mse,n_iter)
File "/~~/anaconda3/lib/python3.7/site-packages/torch/utils/tensorboard/writer.py", line 378, in add_scalars
for tag, scalar_value in tag_scalar_dict.items():
AttributeError: 'Tensor' object has no attribute 'items'
I tried
writer.add_scalars("MSE",l_mse,n_iter).eval()
writer.add_scalars("MSE",l_mse.item(),n_iter)
writer.add_scalars("MSE",l_mse.detach().cpu().numpy(),n_iter)
but still not work well.
tensorboard:1.15.0
tenosrboard-plugin-wit 1.6.0.post3
pytorch:1.5.0