You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to darts documentation, the inner model_air.model of type darts.models.forecasting.tcn_model._TCNModule (derived from PLPastCovariatesModule) can be serialized to ONNX via to_onnx call. However, no matter what I try, I get errors at export: model_air.model.to_onnx('model_air.onnx')
produces ValueError: Could not export to ONNX since neither input_sample nor model.example_input_array attribute is set.
Then
This feature is not officially supported yet (I hope to be able to back at it sometimes soon) but you can find a workaround in #1521.
Note that once the model is exported to this format, you will be responsible for generating the inputs so make sure to have a look at the Dataset class associated with the forecasting model class in order to have an idea of the order of the features for example.
Hi @madtoinou, thanks for reply, the workaround is helpful.
After recovering the _TCNModule model from ONNX, and preparing the Dataset accordingly, how do I use it? the _TCNModule object is hosted by a TCNModel instance, should I create it with same init params and overwrite its model attribute with the recovered one from onnx?
Once you have exported the weights from the model to the ONNX format, you are technically outside of Darts boundaries; you need to then load them either in an inference runtime or another framework (see https://onnx.ai/get-started.html). If you want to stay in the Darts/Python environment, we would recommend using checkpoints instead of the ONNX format to export the model.
I have a TCNModel that is trained on a time series:
According to darts documentation, the inner
model_air.model
of typedarts.models.forecasting.tcn_model._TCNModule
(derived fromPLPastCovariatesModule
) can be serialized to ONNX viato_onnx
call. However, no matter what I try, I get errors at export:model_air.model.to_onnx('model_air.onnx')
produces
ValueError: Could not export to ONNX since neither input_sample nor model.example_input_array attribute is set.
Then
outputs
ValueError: not enough values to unpack (expected 2, got 1)
and
produces
TypeError: _TCNModule.forward() takes 2 positional arguments but 3 were given
.What input value should I give to model_air.model.to_onnx()?
The text was updated successfully, but these errors were encountered: