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
After training a model in Python, I cannot use the trained PyTorch model with DJL.
I always get different exceptions when trying to fix code, but did not manage to make it work.
Error Message
Using the predict method:
Exception in thread "main" ai.djl.translate.TranslateException: ai.djl.engine.EngineException: Expected at most 7 argument(s) for operator 'forward', but received 8 argument(s). Declaration: forward(__torch__.gluonts.torch.model.deepar.lightning_module.DeepARLightningModule self, Tensor cat_feature_slice, Tensor feat_static_real, Tensor a, Tensor past_target, Tensor past_observed_values, Tensor future_time_feat) -> Tensor
at ai.djl.inference.Predictor.batchPredict(Predictor.java:192)
at ai.djl.inference.Predictor.predict(Predictor.java:129)
at Main.predict(Main.java:50)
at Main.main(Main.java:28)
Caused by: ai.djl.engine.EngineException: Expected at most 7 argument(s) for operator 'forward', but received 8 argument(s). Declaration: forward(__torch__.gluonts.torch.model.deepar.lightning_module.DeepARLightningModule self, Tensor cat_feature_slice, Tensor feat_static_real, Tensor a, Tensor past_target, Tensor past_observed_values, Tensor future_time_feat) -> Tensor
at ai.djl.pytorch.jni.PyTorchLibrary.moduleRunMethod(Native Method)
at ai.djl.pytorch.jni.IValueUtils.forward(IValueUtils.java:57)
at ai.djl.pytorch.engine.PtSymbolBlock.forwardInternal(PtSymbolBlock.java:146)
at ai.djl.nn.AbstractBaseBlock.forward(AbstractBaseBlock.java:79)
at ai.djl.nn.Block.forward(Block.java:127)
at ai.djl.inference.Predictor.predictInternal(Predictor.java:143)
at ai.djl.inference.Predictor.batchPredict(Predictor.java:183)
... 3 more
Using the predict1 method:
Exception in thread "main" ai.djl.translate.TranslateException: ai.djl.nn.UninitializedParameterException: The array for parameter "embedding" has not been initialized
at ai.djl.inference.Predictor.batchPredict(Predictor.java:192)
at ai.djl.inference.Predictor.predict(Predictor.java:129)
at Main.predict1(Main.java:66)
at Main.main(Main.java:29)
Caused by: ai.djl.nn.UninitializedParameterException: The array for parameter "embedding" has not been initialized
at ai.djl.nn.Parameter.getArray(Parameter.java:133)
at ai.djl.training.ParameterStore.getValue(ParameterStore.java:109)
at ai.djl.timeseries.block.FeatureEmbedding.forwardInternal(FeatureEmbedding.java:58)
at ai.djl.nn.AbstractBaseBlock.forward(AbstractBaseBlock.java:79)
at ai.djl.timeseries.block.FeatureEmbedder.forwardInternal(FeatureEmbedder.java:73)
at ai.djl.nn.AbstractBaseBlock.forward(AbstractBaseBlock.java:79)
at ai.djl.nn.Block.forward(Block.java:127)
at ai.djl.timeseries.model.deepar.DeepARNetwork.unrollLaggedRnn(DeepARNetwork.java:219)
at ai.djl.timeseries.model.deepar.DeepARPredictionNetwork.forwardInternal(DeepARPredictionNetwork.java:47)
at ai.djl.nn.AbstractBaseBlock.forward(AbstractBaseBlock.java:79)
at ai.djl.nn.Block.forward(Block.java:127)
at ai.djl.inference.Predictor.predictInternal(Predictor.java:143)
at ai.djl.inference.Predictor.batchPredict(Predictor.java:183)
... 3 more
How to Reproduce?
You can comment out the first predict to get a different exception.
Put the trained model (model.pt) inside the data folder.
Run the Main.java
What have you tried to solve it?
I tried to read some examples, to debug it, but I found nothing interesting.
The documentation seems outdated, as the Python code to export models needs to be modified to be able to export a model.
Environment Info
Running on Windows.
I used jars downloaded from Maven:
api-0.26.0.jar
basicdataset-0.26.0.jar
pytorch-engine-0.26.0.jar
pytorch-jni-1.13.1-0.26.0.jar
pytorch-native-cpu-1.13.1-win-x86_64.jar
pytorch-native-cpu-1.13.1.jar
timeseries-0.26.0.jar
The text was updated successfully, but these errors were encountered:
Description
After training a model in Python, I cannot use the trained PyTorch model with DJL.
I always get different exceptions when trying to fix code, but did not manage to make it work.
Error Message
Using the predict method:
Using the predict1 method:
How to Reproduce?
You can comment out the first predict to get a different exception.
Steps to reproduce
data
folder.What have you tried to solve it?
I tried to read some examples, to debug it, but I found nothing interesting.
The documentation seems outdated, as the Python code to export models needs to be modified to be able to export a model.
Environment Info
Running on Windows.
I used jars downloaded from Maven:
The text was updated successfully, but these errors were encountered: