Skip to content

Error with inputs on a model converted onnx->torch #515

@ksaur

Description

@ksaur

For this model and data, a user reported the following error when converting their model from onnx to torch:

import onnx
from hummingbird.ml import convert
from hummingbird.ml import constants
import pandas as pd

m = "/root/hummingbird/tests/errorcode/mymodel.onnx"
csvstr="/root/hummingbird/tests/errorcode/X.csv"
csv=pd.read_csv(csvstr)

with open(m, 'rb') as binary_file:
    modstr = binary_file.read()

hbout = convert( onnx.load_from_string(modstr),'torch',  csv)

# this will give the error below
hbout.predict(csv)
Traceback (most recent call last):
  File "/root/hummingbird/tests/errorcode/colserror.py", line 16, in <module>
    hbout.predict(csv)
  File "/root/hummingbird/hummingbird/ml/containers/_sklearn_api_containers.py", line 119, in predict
    return self._run(self._predict, *inputs)
  File "/root/hummingbird/hummingbird/ml/containers/_sklearn_api_containers.py", line 67, in _run
    return function(*inputs)
  File "/root/hummingbird/hummingbird/ml/containers/sklearn/pytorch_containers.py", line 192, in _predict
    return self.model.forward(*inputs)[0].cpu().numpy().ravel()
  File "/root/hummingbird/hummingbird/ml/_executor.py", line 73, in forward
    self._input_names
AssertionError: number of inputs or number of columns in the dataframe do not match with the expected number of inputs ['loc', 'v_g_', 'ev_g_', 'iv_g_', 'n', 'v', 'l', 'd', 'i', 'e', 'b', 't', 'lOCode', 'lOComment', 'lOBlank', 'lOCodeAndComment', 'uniq_Op', 'total_Op', 'total_Opnd', 'branchCount']

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions