Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
312shan opened this issue Feb 2, 2019 · 2 comments

Comments

@312shan
Copy link

312shan commented Feb 2, 2019

Traceback (most recent call last):
File "transE_pytorch.py", line 255, in
agent.append(trainCurve, epoch, total_loss[0])
File "/home/shan/venv/lib/python3.5/site-packages/hyperboard/agent.py", line 45, in append
value = value,
File "/usr/lib/python3.5/json/init.py", line 230, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.5/json/encoder.py", line 198, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.5/json/encoder.py", line 256, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.5/json/encoder.py", line 179, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: tensor(253923.8438, device='cuda:0') is not JSON serializable

agent 报错,请问你用的 pyTorch 和 hyperboard 版本是多少呢?

@tabVersion
Copy link

The same problem. It occurs on every dataset.

@tabVersion
Copy link

Change agent.append(trainCurve, epoch, total_loss[0]) to agent.append(trainCurve, epoch, total_loss.cpu().numpy()[0]) may solve the problem.
It works on python3.5 and pytorch1.1.0.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants