Skip to content

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

Open
@sumanismcse

Description

@sumanismcse

### 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.
---------------------------------------------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is neededquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions