onnx / onnx/models

run_onnx_squad.py fails with "Model requires 4 inputs. Input Feed contains 3"

Open
#216 4 comments 0 reactions 1 assignee View on GitHub

@vinitra-zz is already working on this.

Since Feb 4, 2020.

Dominant language
Jupyter Notebook
Stars
9.8k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

run_onnx_squad.py from
https://github.com/onnx/models/tree/master/text/machine_comprehension/bert-squad
fails with exception:
"Model requires 4 inputs. Input Feed contains 3"

Steps to repro:
clone that repo

git lfs fetch --include=text/machine_comprehension/bert-squad/model/bertsquad10.onnx.tar.gz

wait for download

extract the real onnx file from the local git cache (could nt find a better way):
$ file ~/repos/models/.git/lfs/objects/1c/ec/1cec14b36fac3e09b2ea54b8de297e12bafabd0fb9d123ad10b6d45459a835a6
/home/wtambellini/repos/models/.git/lfs/objects/1c/ec/1cec14b36fac3e09b2ea54b8de297e12bafabd0fb9d123ad10b6d45459a835a6: gzip compressed data, was "bert.onnx.onnx",
to
text/machine_comprehension/bert-squad/model/bertsquad10.onnx

create the inputs.json as explained there:
https://github.com/onnx/models/tree/master/text/machine_comprehension/bert-squad

download the vocab file from the zip bert model from the bert repo :
https://storage.googleapis.com/bert_models/2018_10_18/uncased_L-12_H-768_A-12.zip

install a recent onnxrt :
$ sudo pip3.5 install --upgrade onnxruntime
Collecting onnxruntime
Downloading https://files.pythonhosted.org/packages/2a/26/52b66fcea1a79b1c873df22bc9844895e6b1ef356c5bb7ee4da260af2ad2/onnxruntime-0.5.0-cp35-cp35m-manylinux2010_x86_64.whl (3.2MB)
100% |████████████████████████████████| 3.2MB 219kB/s
Installing collected packages: onnxruntime
Found existing installation: onnxruntime 0.2.1
Uninstalling onnxruntime-0.2.1:
Successfully uninstalled onnxruntime-0.2.1
Successfully installed onnxruntime-0.5.0

try to run a simple inference :
python3.5 dependencies/run_onnx_squad.py --model model/bertsquad10.onnx --vocab_file ~/Downloads/bert/uncased_L-12_H-768_A-12/vocab.txt --predict_file inputs.json --output /tmp

See that the onnx expects 4 inputs but the py script only gives 3 :

onnxrt expected inputs:
NodeArg(name='unique_ids_raw_output___9:0', type='tensor(int64)', shape=['unk__485'])
NodeArg(name='segment_ids:0', type='tensor(int64)', shape=['unk__486', 256])
NodeArg(name='input_mask:0', type='tensor(int64)', shape=['unk__487', 256])
NodeArg(name='input_ids:0', type='tensor(int64)', shape=['unk__488', 256])

input data is created line 556 with :
data = {"input_ids:0": input_ids[idx:idx + bs],
"input_mask:0": input_mask[idx:idx + bs],
"segment_ids:0": segment_ids[idx:idx + bs]
}
so indeed, 'unique_ids_raw_output___9:0' is missing.

According to the doc, the missing input is :
"label_ids: one-hot encoded labels for the text "

Kind

Contributor guide

No contributing guide indexed for this repository

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.