Skip to content

Commit e255c00

Browse files
authored
Merge pull request #1211 from Azure/release_update/Release-72
update samples from Release-72 as a part of SDK release
2 parents 58e584e + 7871e37 commit e255c00

File tree

2 files changed

+13
-4
lines changed
  • how-to-use-azureml/automated-machine-learning/forecasting-beer-remote

2 files changed

+13
-4
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Azure Machine Learning service example notebooks
22

3-
> A community-driven repository of training and scoring examples can be found at https://github.com/Azure/azureml-examples
4-
53
This repository contains example notebooks demonstrating the [Azure Machine Learning](https://azure.microsoft.com/en-us/services/machine-learning-service/) Python SDK which allows you to build, train, deploy and manage machine learning solutions using Azure. The AML SDK allows you the choice of using local or cloud compute resources, while managing and maintaining the complete data science workflow from the cloud.
64

75
![Azure ML Workflow](https://raw.githubusercontent.com/MicrosoftDocs/azure-docs/master/articles/machine-learning/media/concept-azure-machine-learning-architecture/workflow.png)

how-to-use-azureml/automated-machine-learning/forecasting-beer-remote/infer.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from azureml.automl.runtime.shared.score import scoring, constants
1111
from azureml.core import Run
1212

13+
import torch
14+
1315

1416
def align_outputs(y_predicted, X_trans, X_test, y_test,
1517
predicted_column_name='predicted',
@@ -221,6 +223,10 @@ def MAPE(actual, pred):
221223
return np.mean(APE(actual_safe, pred_safe))
222224

223225

226+
def map_location_cuda(storage, loc):
227+
return storage.cuda()
228+
229+
224230
parser = argparse.ArgumentParser()
225231
parser.add_argument(
226232
'--max_horizon', type=int, dest='max_horizon',
@@ -274,8 +280,13 @@ def MAPE(actual, pred):
274280
y_lookback_df = lookback_dataset.with_timestamp_columns(
275281
None).keep_columns(columns=[target_column_name])
276282

277-
fitted_model = joblib.load(model_path)
278-
283+
# Load the trained model with torch.
284+
if torch.cuda.is_available():
285+
map_location = map_location_cuda
286+
else:
287+
map_location = 'cpu'
288+
with open(model_path, 'rb') as fh:
289+
fitted_model = torch.load(fh, map_location=map_location)
279290

280291
if hasattr(fitted_model, 'get_lookback'):
281292
lookback = fitted_model.get_lookback()

0 commit comments

Comments
 (0)