DCA icon indicating copy to clipboard operation
DCA copied to clipboard

TypeError: Object of type 'Tensor' is not JSON serializable

Open hieu-lam opened this issue 3 years ago • 7 comments

Hi,

We have successfully trained the model, but we got a problem while saving the model to a file. The exception is as below:

epoch 54 total loss 0.20950795884999707 0.00021984046049317634 aida-A micro F1: 0.9299655568312285 aida-B micro F1: 0.9415830546265329 msnbc micro F1: 0.9395562356541699 aquaint micro F1: 0.8797202797202797 ace2004 micro F1: 0.8853118712273641 clueweb micro F1: 0.7417355371900826 wikipedia micro F1: 0.7820427483174321 change learning rate to 0.0001 att_mat_diag tok_score_mat_diag entity2entity_mat_diag entity2entity_score_mat_diag knowledge2entity_mat_diag knowledge2entity_score_mat_diag type_emb cnn.weight cnn.bias score_combine.0.weight score_combine.0.bias score_combine.3.weight score_combine.3.bias save model to model/ Traceback (most recent call last): File "main.py", line 225, in ranker.train(conll.train, dev_datasets, config) File "../DCA/ed_ranker.py", line 1032, in train self.model.save(self.args.model_path) File "../DCA/abstract_word_entity.py", line 78, in save json.dump(config, f) File "/usr/lib64/python3.6/json/init.py", line 179, in dump for chunk in iterable: File "/usr/lib64/python3.6/json/encoder.py", line 430, in _iterencode yield from _iterencode_dict(o, _current_indent_level) File "/usr/lib64/python3.6/json/encoder.py", line 404, in _iterencode_dict yield from chunks File "/usr/lib64/python3.6/json/encoder.py", line 325, in _iterencode_list yield from chunks File "/usr/lib64/python3.6/json/encoder.py", line 437, in _iterencode o = _default(o) File "/usr/lib64/python3.6/json/encoder.py", line 180, in default o.class.name) TypeError: Object of type 'Tensor' is not JSON serializable

Previously we got the same issue as #7 , but we followed the instruction and got that fixed.

We hope you can assist us with this issue :-)

hieu-lam avatar Feb 23 '21 11:02 hieu-lam