Skip to content

Commit ce3214b

Browse files
committed
fix name
1 parent 53199d1 commit ce3214b

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

docs/how-to-deploy-to-aci/how-to-deploy-to-aci.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
# PREREQ: load workspace info
88
# import azureml.core
9-
# <load_workspace>
9+
# <load-workspace>
1010
from azureml.core import Workspace
1111
ws = Workspace.from_config()
12-
# </load_workspace>
12+
# </load-workspace>
1313

1414
scorepy_content = "import json\nimport numpy as np\nimport os\nimport pickle\nfrom sklearn.externals import joblib\nfrom sklearn.linear_model import LogisticRegression\n\nfrom azureml.core.model import Model\n\ndef init():\n global model\n # retreive the path to the model file using the model name\n model_path = Model.get_model_path('sklearn_mnist')\n model = joblib.load(model_path)\n\ndef run(raw_data):\n data = np.array(json.loads(raw_data)['data'])\n # make prediction\n y_hat = model.predict(data)\n return json.dumps(y_hat.tolist())"
1515
print(scorepy_content)

docs/how-to-deploy-to-aci/utils.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
import gzip
5+
import numpy as np
6+
import struct
7+
8+
9+
# load compressed MNIST gz files and return numpy arrays
10+
def load_data(filename, label=False):
11+
with gzip.open(filename) as gz:
12+
struct.unpack('I', gz.read(4))
13+
n_items = struct.unpack('>I', gz.read(4))
14+
if not label:
15+
n_rows = struct.unpack('>I', gz.read(4))[0]
16+
n_cols = struct.unpack('>I', gz.read(4))[0]
17+
res = np.frombuffer(gz.read(n_items[0] * n_rows * n_cols), dtype=np.uint8)
18+
res = res.reshape(n_items[0], n_rows * n_cols)
19+
else:
20+
res = np.frombuffer(gz.read(n_items[0]), dtype=np.uint8)
21+
res = res.reshape(n_items[0], 1)
22+
return res
23+
24+
25+
# one-hot encode a 1-D array
26+
def one_hot_encode(array, num_of_classes):
27+
return np.eye(num_of_classes)[array.reshape(-1)]

0 commit comments

Comments
 (0)