Azure / Azure/MachineLearningNotebooks

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

未關閉
#1,613 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Jupyter Notebook
星號
4.4k
分支
2.6k
PR 合併指標
30 天內沒有已合併 PR

描述

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**

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

Reproduce the failure by loading outputs/model.pt with torch.load(..., map_location='cpu') and inspect the traceback locations in forecast_tcn_wrapper.py and forecast_wrapper.py, especially __setstate__. Compare the generated outputs/scoring_file_.py with the wrapper state being restored. Done means the saved TCNForecaster deserializes successfully locally and on a compute instance using the documented loading path.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
azure, python, pytorch
領域
machine-learning
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。