当前位置:网站首页>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)
- DNS attack details
- allennlp 中的TypeError: Object of type Tensor is not JSON serializable错误
- 使用MAME32K进行联机游戏
- MySQL has no collation factor of order by
- CAD secondary development object
- 【BERT,GPT+KG调研】Pretrain model融合knowledge的论文集锦
- Oracle segment advisor, how to deal with row link row migration, reduce high water level
- Message queue fnd in Oracle EBS_ msg_ pub、fnd_ Application of message in pl/sql
- 腾讯机试题
猜你喜欢
随机推荐
php中根据数字月份返回月份的英文缩写
Classloader and parental delegation mechanism
Oracle apex 21.2 installation and one click deployment
Proteus -- RS-232 dual computer communication
SSM student achievement information management system
Ceaspectuss shipping company shipping artificial intelligence products, anytime, anywhere container inspection and reporting to achieve cloud yard, shipping company intelligent digital container contr
类加载器及双亲委派机制
使用Matlab实现:幂法、反幂法(原点位移)
parser.parse_args 布尔值类型将False解析为True
CSRF attack
【MEDICAL】Attend to Medical Ontologies: Content Selection for Clinical Abstractive Summarization
ORACLE 11G SYSAUX表空间满处理及move和shrink区别
一个中年程序员学习中国近代史的小结
The boss said: whoever wants to use double to define the amount of goods, just pack up and go
Pratique et réflexion sur l'entrepôt de données hors ligne et le développement Bi
Laravel8中的find_in_set、upsert的使用方法
php中计算两个日期之前相差多少天、月、年
Oracle EBS database monitoring -zabbix+zabbix-agent2+orabbix
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
优化方法:常用数学符号的含义









