-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Object of type 'Tensor' is not JSON serializable #258
Comments
"Note: The current software works well with PyTorch 0.1-0.3. PyTorch 0.4 support will be added by the end of May." |
did this help? fossasia/visdom#554 |
If like me you just wanted to save the dict of tensors in a human readable way check this out: https://discuss.pytorch.org/t/typeerror-tensor-is-not-json-serializable/36065/3 or https://stackoverflow.com/questions/12943819/how-to-prettyprint-a-json-file/66180687#66180687. |
Hello,I run your train.py with GPU and the newest pytorch >>> torch.version '0.4.0a0+5463a4a',THEN I have this problem ,I haven't use pytorch and visdom before ,so I don't know how to fix it ,Could you please help me with this problem?
Traceback (most recent call last):
File "/home/yt/anaconda3/lib/python3.6/site-packages/visdom/init.py", line 261, in _send
data=json.dumps(msg),
File "/home/yt/anaconda3/lib/python3.6/json/init.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/home/yt/anaconda3/lib/python3.6/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/home/yt/anaconda3/lib/python3.6/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/home/yt/anaconda3/lib/python3.6/json/encoder.py", line 180, in default
o.class.name)
TypeError: Object of type 'Tensor' is not JSON serializable
(epoch: 1, iters: 300, time: 0.278, data: 0.001) D_A: 0.164 G_A: 0.396 cycle_A: 1.978 idt_A: 1.903 D_B: 0.312 G_B: 0.730 cycle_B: 4.014 idt_B: 0.921
Exception in user code:
Traceback (most recent call last):
File "/home/yt/anaconda3/lib/python3.6/site-packages/visdom/init.py", line 261, in _send
data=json.dumps(msg),
File "/home/yt/anaconda3/lib/python3.6/json/init.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/home/yt/anaconda3/lib/python3.6/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/home/yt/anaconda3/lib/python3.6/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/home/yt/anaconda3/lib/python3.6/json/encoder.py", line 180, in default
o.class.name)
TypeError: Object of type 'Tensor' is not JSON serializable
Traceback (most recent call last):
File "train.py", line 35, in
visualizer.display_current_results(model.get_current_visuals(), epoch, save_result)
File "/media/yt/SearchforGraduationDesign/pytorch-CycleGAN-and-pix2pix/util/visualizer.py", line 53, in display_current_results
image_numpy = util.tensor2im(image)
File "/media/yt/SearchforGraduationDesign/pytorch-CycleGAN-and-pix2pix/util/util.py", line 30, in tensor2im
image_numpy = image_tensor[0].cpu().float().numpy()
RuntimeError: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead.
The text was updated successfully, but these errors were encountered: