shenweichen / shenweichen/DeepCTR-Torch

How to export DeepCTR model to onnx ?

Open
#83 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
3.5k
Forks
733
PR merge metrics
No merged PRs in 30d

Description

Please refer to the FAQ in doc and search for the related issues before you ask the question.

Describe the question(问题描述)
I would like to export model to onnx format, so I can use it for example with Apache PredictionIO

Additional context
I tried with :

    dummy_input = np.array([np.array([[0]]), np.array([[0]])])
    pred_ans = model.predict(dummy_input, 100)
    print(pred_ans)
    torch.onnx.export(model, (dummy_input), "deepCTR.onnx")

predict works well, I am getting: [[0.0065056]]
but wwith onnx.export, I am getting error with this trace:

RuntimeError: Only tuples, lists and Variables supported as JIT inputs/outputs. Dictionaries and strings are also accepted but their usage is not recommended. But got unsupported type numpy.ndarray

Operating environment(运行环境):

  • python version: 3.7
  • torch version: 1.4.0
  • deepctr-torch version: 0.1.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the FAQ and related issues first, then reproduce the failure from the provided model.predict and torch.onnx.export calls using the stated Python 3.7, PyTorch 1.4.0, and deepctr-torch 0.1.0 versions. Done means the DeepCTR model can be exported to ONNX for use with Apache PredictionIO, with the supported input form and limitations documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.