我想使用jit编译任意nn模块
在我的代码中,我将我的值与dict进行比较,它会抛出一个错误
"""
if type(json_data) is dict:
~~~~ <--- HERE
简单地说,任何与dict进行比较的代码:
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'
相关的:
目前没有回答
相关问题 更多 >
编程相关推荐