当前位置:网站首页>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 .
边栏推荐
- DNS攻击详解
- CSRF攻击
- Sqli-labs customs clearance (less2-less5)
- 【Torch】解决tensor参数有梯度,weight不更新的若干思路
- @Transitional step pit
- oracle EBS标准表的后缀解释说明
- Practice and thinking of offline data warehouse and Bi development
- php中的数字金额转换大写数字
- Oracle 11.2.0.3 handles the problem of continuous growth of sysaux table space without downtime
- Sqli labs customs clearance summary-page1
猜你喜欢
SSM实验室设备管理
Build FRP for intranet penetration
MySQL无order by的排序规则因素
Spark的原理解析
外币记账及重估总账余额表变化(下)
Oracle EBS database monitoring -zabbix+zabbix-agent2+orabbix
spark sql任务性能优化(基础)
腾讯机试题
The boss said: whoever wants to use double to define the amount of goods, just pack up and go
User login function: simple but difficult
随机推荐
【信息检索导论】第一章 布尔检索
php中通过集合collect的方法来实现把某个值插入到数组中指定的位置
Classloader and parental delegation mechanism
MapReduce concepts and cases (Shang Silicon Valley Learning Notes)
MySQL has no collation factor of order by
Oracle RMAN semi automatic recovery script restore phase
Conda 创建,复制,分享虚拟环境
Oracle general ledger balance table GL for foreign currency bookkeeping_ Balance change (Part 1)
Principle analysis of spark
Build FRP for intranet penetration
Laravel8中的find_in_set、upsert的使用方法
@Transitional step pit
TCP攻击
解决万恶的open failed: ENOENT (No such file or directory)/(Operation not permitted)
MySQL中的正则表达式
sparksql数据倾斜那些事儿
ORACLE APEX 21.2安裝及一鍵部署
view的绘制机制(三)
oracle apex ajax process + dy 校验
How to call WebService in PHP development environment?