大佬教程收集整理的这篇文章主要介绍了在 pytorch 中从 jit 创建检查点时,如何修复 RuntimeError: builtin cannot be used as a value (with a dict)?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想使用 jit 编译任意 nn 模块。
在我的代码中,我将我的值与字典进行比较,但它会引发错误。
"""
if type(Json_data) is Dict:
~~~~ <--- HERE
简单,任何与字典进行比较的代码:
class Node(object):
def __init__(self):
pass
@classmethod
def from_Json(cls,Json_data):
if type(Json_data) is Dict:
node_data = next(iter(Json_data))
assert type(Json_data[node_data]) is List
node_children = [cls.from_Json(child) for child in Json_data[node_data]]
return Node(node_data,node_children)
else:
return Node(Json_data)
Jit 成为我的检查点。
conda
,pip
,来源):conda将任意自定义 nn 模块编译为 jit
错误:
/Users/brando/anaconda3/envs/coq_gym/bin/python /Applications/PyCharm.app/Contents/plugins/python/Helpers/pydev/pydevd.py --cmd-line --multiproc --qt-support=auto --clIEnt 127.0.0.1 --port 59213 --file /Users/brando/ML4Coq/playground/running_pytorch_ocaml/treenn2jit_ckpt.py
Connected to pydev deBUGger (build 203.7148.72)
1.7.1
TraceBACk (most recent call last):
file "/Users/brando/anaconda3/envs/coq_gym/lib/python3.7/site-packages/torch/jit/_recursive.py",line 680,in compile_unbound_method
create_methods_and_propertIEs_from_stubs(concrete_type,(stub,),())
file "/Users/brando/anaconda3/envs/coq_gym/lib/python3.7/site-packages/torch/jit/_recursive.py",line 304,in create_methods_and_propertIEs_from_stubs
concrete_type._create_methods_and_propertIEs(property_defs,property_rcbs,method_defs,method_rcbs,method_defaults)
file "/Users/brando/anaconda3/envs/coq_gym/lib/python3.7/site-packages/torch/jit/Annotations.py",line 330,in try_Ann_to_type
torch.jit._script._recursive_compile_class(Ann,loC)
file "/Users/brando/anaconda3/envs/coq_gym/lib/python3.7/site-packages/torch/jit/_script.py",line 1056,in _recursive_compile_class
_compile_and_register_class(obj,rcb,_qual_Name)
file "/Users/brando/anaconda3/envs/coq_gym/lib/python3.7/site-packages/torch/jit/_script.py",line 64,in _compile_and_register_class
torch._C._jit_script_class_compile(qualifIEd_name,ast,defaults,rcb)
RuntimeError:
builTin cAnnot be used as a value:
file "/Users/brando/ML4Coq/ml4coq-proj/embeddings_zoo/extract_tactic_from_lasse_data.py",line 56
term = String
"""
if type(Json_data) is Dict:
~~~~ <--- HERE
node_data = next(iter(Json_data))
assert type(Json_data[node_data]) is List
'Node.from_Json' is being compiled since it was called from '__torch__.embeddings_zoo.extract_tactic_from_lasse_data.Node'
相关:
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
@H_674_73@以上是大佬教程为你收集整理的在 pytorch 中从 jit 创建检查点时,如何修复 RuntimeError: builtin cannot be used as a value (with a dict)?全部内容,希望文章能够帮你解决在 pytorch 中从 jit 创建检查点时,如何修复 RuntimeError: builtin cannot be used as a value (with a dict)?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。