Skip to content

Convert pytorch model to onnx file and onnx file to tensorflow model for better data serving in the app #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sumanismcse opened this issue Oct 3, 2019 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested

Comments

@sumanismcse
Copy link
Owner

sumanismcse commented Oct 3, 2019

### When I tried to convert pytorch model to onnx file,This Happened:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-33-a9d25627b347> in <module>()
     10 # Export the trained model to ONNX
     11 dummy_input = Variable(torch.randn(1, 1, 28, 28)) # one black and white 28 x 28 picture will be the input to the model
---> 12 torch.onnx.export(trained_model, dummy_input, "sentiment.onnx")

9 frames
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in _slow_forward(self, *input, **kwargs)
    529         tracing_state._traced_module_stack.append(self)
    530         try:
--> 531             result = self.forward(*input, **kwargs)
    532         finally:
    533             tracing_state.pop_scope()

TypeError: forward() missing 1 required positional argument: 'hidden'

###The same happened on the onnx file to tensorflow model:

----------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-34-a405ea78dbb6> in <module>()
      1 
----> 2 import onnx
      3 import warnings
      4 from onnx_tf.backend import prepare
      5 

ModuleNotFoundError: No module named 'onnx'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
@sumanismcse sumanismcse added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested labels Oct 3, 2019
@sumanismcse sumanismcse pinned this issue Oct 17, 2019
@Padia-jay
Copy link

facing the same issue, anyone found any solutions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants