python系列json.dumps()函数报错
问题发生异常: SyntaxErrorinvalid syntax (<unknown>, line 124)During handling of the above exception, another exception occurred:During handling of the above exception, another exception occurred:File
问题
发生异常: SyntaxError
invalid syntax (<unknown>, line 124)
During handling of the above exception, another exception occurred:
During handling of the above exception, another exception occurred:
File "/mmsegmentation/tools/train.py", line 103, in main
cfg.dump(__)
File "/mmsegmentation/tools/train.py", line 166, in <module>
main()
注:无法显示具体报错问题
原因
json.dumps()用于将dict类型的数据转成str,但如果直接将dict类型的数据写入json文件中会发生报错。
办法
将字典里的键值对由直接的类型名换成字符串
norm_layer=nn.BatchNorm2d,
换
norm_layer='BatchNorm2d',
参考

GitCode 天启AI是一款由 GitCode 团队打造的智能助手,基于先进的LLM(大语言模型)与多智能体 Agent 技术构建,致力于为用户提供高效、智能、多模态的创作与开发支持。它不仅支持自然语言对话,还具备处理文件、生成 PPT、撰写分析报告、开发 Web 应用等多项能力,真正做到“一句话,让 Al帮你完成复杂任务”。
更多推荐
所有评论(0)