mammoth-eu / mammoth-commons

Contains modules with the project's research results
Other
1 stars 6 forks source link

error in demonstrator at step 3 with onnx_ensemble #33

Open arjunroyihrpa opened 1 day ago

arjunroyihrpa commented 1 day ago
Screenshot 2024-11-01 at 12 24 42 Screenshot 2024-11-01 at 12 29 59
maniospas commented 20 hours ago

Hi, since there are no data submitted I fixed the method to the point that it does not create these kinds of errors. You still need sensitive attributes for fairness analysis. For me, it still creates an error that I am not inputting the same data dimensions as the ones the model has been trained on.

Please check if it works on your end. If so, close this issue.

maniospas commented 20 hours ago

To clarify, if I follow the workshop template, I get this:

image

The stack trace is this:

onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: X for the following indices
 index: 1 Got: 33 Expected: 23
 Please fix either the inputs/outputs or the model.
Traceback (most recent call last):
  File "/home/maniospas/Documents/mammoth-commons/demonstrator/backend/handlers/handle_fairness_analysis.py", line 93, in handle_fairness_analysis_post
    result = name_to_runnable[selected_method](
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/maniospas/Documents/mammoth-commons/catalogue/metrics/interactive_report.py", line 50, in interactive_report
    predictions = model.predict(dataset, sensitive)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/maniospas/Documents/mammoth-commons/mammoth/models/onnx_ensemble.py", line 20, in predict
    pred = sum(
           ^^^^
  File "/home/maniospas/Documents/mammoth-commons/mammoth/models/onnx_ensemble.py", line 21, in <genexpr>
    (estimator.predict(X, []) == classes).T * w
     ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/maniospas/Documents/mammoth-commons/mammoth/models/onnx.py", line 18, in predict
    return sess.run([label_name], {input_name: x.astype(self.np_type)})[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/maniospas/Documents/mammoth-commons/venv/lib/python3.12/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 220, in run
    return self._sess.run(output_names, input_feed, run_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: X for the following indices
 index: 1 Got: 33 Expected: 23
 Please fix either the inputs/outputs or the model.