Azure / Azure/MachineLearningNotebooks

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

Đang mở
#1,613 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Jupyter Notebook
Star
4.4k
Fork
2.6k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.