knowledge_representation_pytorch icon indicating copy to clipboard operation
knowledge_representation_pytorch copied to clipboard

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

Open 312shan opened this issue 6 years ago • 2 comments

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 版本是多少呢?

312shan avatar Feb 02 '19 05:02 312shan

The same problem. It occurs on every dataset.

tabVersion avatar May 15 '19 06:05 tabVersion

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.

tabVersion avatar May 16 '19 09:05 tabVersion