tutorials icon indicating copy to clipboard operation
tutorials copied to clipboard

AtrributError

Open shbnm21 opened this issue 6 years ago • 1 comments

I am converting encoder and decoder to onnx format. Everything works fine but as soon as I compare torch_out with caffe2 model it gives AtrributError

np.testing.assert_almost_equal(torch_out.data.cpu().numpy(), c2_out, decimal=3)

In this I am getting AtrributError Nonetype object has no attribute 'data'

torch_out=torch.onnx.export(model,x,model.onnx, verbose=True)

Export function gives the graph but when I print torch_out it prints None but it should print tensor value

And this is causing AtrributError when comparing torch_out with caffe2 model

shbnm21 avatar Jun 21 '19 05:06 shbnm21

【My problem is as follows】: Traceback (most recent call last): File "convert1.py", line 11, in torch.onnx.export(model, dummy_input, "alexnet.onnx", verbose=False, input_names=input_names, output_names=output_names) File "/root/anaconda3/lib/python3.6/site-packages/torch/onnx/init.py", line 168, in export custom_opsets, enable_onnx_checker, use_external_data_format) File "/root/anaconda3/lib/python3.6/site-packages/torch/onnx/utils.py", line 69, in export use_external_data_format=use_external_data_format) File "/root/anaconda3/lib/python3.6/site-packages/torch/onnx/utils.py", line 488, in _export fixed_batch_size=fixed_batch_size) File "/root/anaconda3/lib/python3.6/site-packages/torch/onnx/utils.py", line 334, in _model_to_graph graph, torch_out = _trace_and_get_graph_from_model(model, args, training) File "/root/anaconda3/lib/python3.6/site-packages/torch/onnx/utils.py", line 282, in _trace_and_get_graph_from_model orig_state_dict_keys = _unique_state_dict(model).keys() File "/root/anaconda3/lib/python3.6/site-packages/torch/jit/init.py", line 286, in _unique_state_dict state_dict = module.state_dict(keep_vars=True) AttributeError: 'collections.OrderedDict' object has no attribute 'state_dict'

How to solve this problem?

ruabuliuqiu avatar Aug 05 '20 02:08 ruabuliuqiu