I am going through the ants bees transfer learning tutorial:
https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html 8
Instead of each epoch, I wanted to get results every x amount of batches, so I made a couple of tweaks (which probably doesn’t affect the problem I have):
if num % 100 == 0:
print(‘running_corrects’, running_corrects/( len(inputs) *  num + 1)
running corrects should not be using auto-grad,
and I thought it would be printable.
When I print I get the tensor value:
“running_corrects tensor(0, device=‘cuda:0’)”
however if I try to .numpy or .cpu
I get the error:
AttributeError: 'int' object has no attribute 'numpy'
AttributeError: ‘int’ object has no attribute ‘cpu’
I found this:

  
      github.com/prlz77/ResNeXt.pytorch
  
  
    



Issue: TypeError: tensor(0, device='cuda:0') is not JSON serializable 4


	
	opened by zorrocai
	on 2018-05-10
	
	
	closed by prlz77
	on 2018-05-10
	


when I run the codes following your instructions, "TypeError: tensor(0, device='cuda:0') is not JSON serializable" occurs at the line 167 of...




  
  
    
    
  
  


but don’t want to mess around with the version (unless I have to) as it took me a while to get Pytorch working (Windows 10).
Thank you.