Azure / Azure/MachineLearningNotebooks

TCNForecaster's `output/model.pt` can't be deserialized

Abierto
#1,613 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Jupyter Notebook
Estrellas
4.4k
Forks
2.6k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I set `enable_dnn=True` in the `AutoMLConfig`. The TCNForecaster that is therefore trained stores the model in `outputs/model.pt`.

I try to open the model with this code:

```python
with open(model_path, 'rb') as model_file:
model = torch.load(model_file, map_location='cpu')
```

This code is taken from `outputs/scoring_file_v_.py`. But running this locally or on an compute instance leads to the following error:

```shell
Traceback (most recent call last):
File "test_tcn.py", line 5, in
model = torch.load(model_file, map_location='cpu')
File "/Users/simons/anaconda3/envs/tcn_test/lib/python3.7/site-packages/torch/serialization.py", line 594, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/Users/simons/anaconda3/envs/tcn_test/lib/python3.7/site-packages/torch/serialization.py", line 853, in _load
result = unpickler.load()
File "/Users/simons/anaconda3/envs/tcn_test/lib/python3.7/site-packages/azureml/contrib/automl/dnn/forecasting/wrapper/forecast_tcn_wrapper.py", line 376, in __setstate__
super(ForecastTCNWrapper, self).__setstate__(state)
File "/Users/simons/anaconda3/envs/tcn_test/lib/python3.7/site-packages/azureml/contrib/automl/dnn/forecasting/wrapper/forecast_wrapper.py", line 302, in __setstate__
self.forecaster.device = 'cuda' if torch.cuda.is_available() else 'cpu'
AttributeError: 'NoneType' object has no attribute 'device'
```

I used the exact same code 2 weeks ago and it worked. I guess that something was changed in the serialization of the model. If there is a new, could you please provide a code snippet which is used to deserialize the model.

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: be87853c-7d77-ec34-2bd2-a2f1e7104a3e
* Version Independent ID: 9c3f1114-c842-d0dd-ee02-7fae9974a545
* Content: [azureml.train.automl.AutoMLConfig class - Azure Machine Learning Python](https://docs.microsoft.com/en-us/python/api/azureml-train-automl-client/azureml.train.automl.automlconfig(class)?view=azure-ml-py)
* Content Source: [AzureML-Docset/stable/docs-ref-autogen/azureml-train-automl-client/azureml.train.automl.AutoMLConfig(class).yml](https://github.com/MicrosoftDocs/MachineLearning-Python-pr/blob/live/AzureML-Docset/stable/docs-ref-autogen/azureml-train-automl-client/azureml.train.automl.AutoMLConfig(class).yml)
* Service: **machine-learning**
* Sub-service: **core**
* GitHub Login: @DebFro
* Microsoft Alias: **debfro**

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.