当前位置:网站首页>Typeerror in allenlp: object of type tensor is not JSON serializable error
Typeerror in allenlp: object of type tensor is not JSON serializable error
2022-07-02 07:20:00 【lwgkzl】
Wrong show :
File "/home/yanshangyao/anaconda3/envs/torch14/bin/allennlp", line 8, in <module>
sys.exit(run())
File "/home/yanshangyao/anaconda3/envs/torch14/lib/python3.7/site-packages/allennlp/run.py", line 18, in run
main(prog="allennlp")
File "/home/yanshangyao/anaconda3/envs/torch14/lib/python3.7/site-packages/allennlp/commands/__init__.py", line 102, in main
args.func(args)
File "/home/yanshangyao/anaconda3/envs/torch14/lib/python3.7/site-packages/allennlp/commands/train.py", line 124, in train_model_from_args
args.cache_prefix)
File "/home/yanshangyao/anaconda3/envs/torch14/lib/python3.7/site-packages/allennlp/commands/train.py", line 168, in train_model_from_file
cache_directory, cache_prefix)
File "/home/yanshangyao/anaconda3/envs/torch14/lib/python3.7/site-packages/allennlp/commands/train.py", line 252, in train_model
metrics = trainer.train()
File "/home/yanshangyao/anaconda3/envs/torch14/lib/python3.7/site-packages/allennlp/training/trainer.py", line 529, in train
dump_metrics(os.path.join(self._serialization_dir, f'metrics_epoch_{epoch}.json'), metrics)
File "/home/yanshangyao/anaconda3/envs/torch14/lib/python3.7/site-packages/allennlp/common/util.py", line 419, in dump_metrics
metrics_json = json.dumps(metrics, indent=2)
File "/home/yanshangyao/anaconda3/envs/torch14/lib/python3.7/json/__init__.py", line 238, in dumps
**kw).encode(obj)
File "/home/yanshangyao/anaconda3/envs/torch14/lib/python3.7/json/encoder.py", line 201, in encode
chunks = list(chunks)
File "/home/yanshangyao/anaconda3/envs/torch14/lib/python3.7/json/encoder.py", line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/home/yanshangyao/anaconda3/envs/torch14/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/home/yanshangyao/anaconda3/envs/torch14/lib/python3.7/json/encoder.py", line 438, in _iterencode
o = _default(o)
File "/home/yanshangyao/anaconda3/envs/torch14/lib/python3.7/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Tensor is not JSON serializable
This mistake has happened many times , Every time I forget . First of all, we can see the design in the error report metric, I always thought it was meric It's not in the right format , Do not conform to the json.dumps Standards for , Look carefully and find that the mistake is Object of type Tensor, In other words tensor Format objects cannot dumps, Then we need to be in get_metirc Put it in metric The value inside first becomes a value .
边栏推荐
- 中年人的认知科普
- 如何高效开发一款微信小程序
- 读《敏捷整洁之道:回归本源》后感
- 2021-07-17c /cad secondary development creation circle (5)
- 【信息检索导论】第一章 布尔检索
- 矩阵的Jordan分解实例
- Yolov5 practice: teach object detection by hand
- DNS attack details
- Sqli labs customs clearance summary-page2
- A summary of a middle-aged programmer's study of modern Chinese history
猜你喜欢
SSM student achievement information management system
Spark SQL task performance optimization (basic)
【信息检索导论】第三章 容错式检索
DNS attack details
ssm垃圾分类管理系统
Network security -- intrusion detection of emergency response
【信息检索导论】第二章 词项词典与倒排记录表
mapreduce概念和案例(尚硅谷学习笔记)
Sqli labs customs clearance summary-page1
spark sql任务性能优化(基础)
随机推荐
User login function: simple but difficult
php中在二维数组中根据值返回对应的键值
ssm人事管理系统
使用 Compose 实现可见 ScrollBar
php中根据数字月份返回月份的英文缩写
Sqli labs customs clearance summary-page2
How to efficiently develop a wechat applet
离线数仓和bi开发的实践和思考
【调参Tricks】WhiteningBERT: An Easy Unsupervised Sentence Embedding Approach
RMAN incremental recovery example (1) - without unbacked archive logs
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
Pratique et réflexion sur l'entrepôt de données hors ligne et le développement Bi
php中计算两个日期之前相差多少天、月、年
Agile development of software development pattern (scrum)
一个中年程序员学习中国近代史的小结
ORACLE 11G利用 ORDS+pljson来实现json_table 效果
Classloader and parental delegation mechanism
A summary of a middle-aged programmer's study of modern Chinese history
MapReduce concepts and cases (Shang Silicon Valley Learning Notes)
CAD secondary development object