mirror of
https://github.com/Azure/MachineLearningNotebooks.git
synced 2025-12-22 18:42:41 -05:00
Update notebooks
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"# 03. Training MNIST dataset with hyperparameter tuning & deploy to ACI\n",
|
||||
"# 03. Training, hyperparameter tune, and deploy with TensorFlow\n",
|
||||
"\n",
|
||||
"## Introduction\n",
|
||||
"This tutorial shows how to train a simple deep neural network using the MNIST dataset and TensorFlow on Azure Machine Learning. MNIST is a popular dataset consisting of 70,000 grayscale images. Each image is a handwritten digit of `28x28` pixels, representing number from 0 to 9. The goal is to create a multi-class classifier to identify the digit each image represents, and deploy it as a web service in Azure.\n",
|
||||
@@ -72,6 +72,28 @@
|
||||
"print(\"Azure ML SDK Version: \", azureml.core.VERSION)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Diagnostics\n",
|
||||
"Opt-in diagnostics for better experience, quality, and security of future releases."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"tags": [
|
||||
"Diagnostics"
|
||||
]
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from azureml.telemetry import set_diagnostics_collection\n",
|
||||
"set_diagnostics_collection(send_diagnostics=True)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -246,17 +268,17 @@
|
||||
"from azureml.core.compute_target import ComputeTargetException\n",
|
||||
"\n",
|
||||
"# choose a name for your cluster\n",
|
||||
"batchai_cluster_name = \"gpucluster\"\n",
|
||||
"cluster_name = \"gpucluster\"\n",
|
||||
"\n",
|
||||
"try:\n",
|
||||
" # look for the existing cluster by name\n",
|
||||
" compute_target = ComputeTarget(workspace=ws, name=batchai_cluster_name)\n",
|
||||
" compute_target = ComputeTarget(workspace=ws, name=cluster_name)\n",
|
||||
" if type(compute_target) is BatchAiCompute:\n",
|
||||
" print('found compute target {}, just use it.'.format(batchai_cluster_name))\n",
|
||||
" print('Found existing compute target {}.'.format(cluster_name))\n",
|
||||
" else:\n",
|
||||
" print('{} exists but it is not a Batch AI cluster. Please choose a different name.'.format(batchai_cluster_name))\n",
|
||||
" print('{} exists but it is not a Batch AI cluster. Please choose a different name.'.format(cluster_name))\n",
|
||||
"except ComputeTargetException:\n",
|
||||
" print('creating a new compute target...')\n",
|
||||
" print('Creating a new compute target...')\n",
|
||||
" compute_config = BatchAiCompute.provisioning_configuration(vm_size=\"STANDARD_NC6\", # GPU-based VM\n",
|
||||
" #vm_priority='lowpriority', # optional\n",
|
||||
" autoscale_enabled=True,\n",
|
||||
@@ -264,7 +286,7 @@
|
||||
" cluster_max_nodes=4)\n",
|
||||
"\n",
|
||||
" # create the cluster\n",
|
||||
" compute_target = ComputeTarget.create(ws, batchai_cluster_name, compute_config)\n",
|
||||
" compute_target = ComputeTarget.create(ws, cluster_name, compute_config)\n",
|
||||
" \n",
|
||||
" # can poll for a minimum number of nodes and for a specific timeout. \n",
|
||||
" # if no min node count is provided it uses the scale settings for the cluster\n",
|
||||
@@ -278,7 +300,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Now that you have created the compute target, let's see what the workspace's `compute_targets()` function returns. You should now see one entry named 'cpucluster' of type BatchAI."
|
||||
"Now that you have created the compute target, let's see what the workspace's `compute_targets()` function returns. You should now see one entry named 'gpucluster' of type BatchAI."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -287,8 +309,9 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for ct in ws.compute_targets():\n",
|
||||
" print(ct.name, ct.type, ct.provisioning_state)"
|
||||
"compute_targets = ws.compute_targets()\n",
|
||||
"for name, ct in compute_targets.items():\n",
|
||||
" print(name, ct.type, ct.provisioning_state)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -338,7 +361,7 @@
|
||||
" parser = argparse.ArgumentParser()\n",
|
||||
" parser.add_argument('--data_folder')\n",
|
||||
"```\n",
|
||||
"2. The script is accessing the Azure ML `Run` object by executing `run = Run.get_submitted_run()`. Further down the script is using the `run` to report the training accuracy and the validation accuracy as training progresses.\n",
|
||||
"2. The script is accessing the Azure ML `Run` object by executing `run = Run.get_context()`. Further down the script is using the `run` to report the training accuracy and the validation accuracy as training progresses.\n",
|
||||
"```\n",
|
||||
" run.log('training_acc', np.float(acc_train))\n",
|
||||
" run.log('validation_acc', np.float(acc_val))\n",
|
||||
@@ -1056,14 +1079,17 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for model in ws.models():\n",
|
||||
" print(\"Model:\", model.name, model.id)\n",
|
||||
"\n",
|
||||
"for image in ws.images():\n",
|
||||
" print(\"Image:\", image.name, image.image_location)\n",
|
||||
"\n",
|
||||
"for webservice in ws.webservices():\n",
|
||||
" print(\"Webservice:\", webservice.name, webservice.scoring_uri)"
|
||||
"models = ws.models()\n",
|
||||
"for name, model in models.items():\n",
|
||||
" print(\"Model: {}, ID: {}\".format(name, model.id))\n",
|
||||
" \n",
|
||||
"images = ws.images()\n",
|
||||
"for name, image in images.items():\n",
|
||||
" print(\"Image: {}, location: {}\".format(name, image.image_location))\n",
|
||||
" \n",
|
||||
"webservices = ws.webservices()\n",
|
||||
"for name, webservice in webservices.items():\n",
|
||||
" print(\"Webservice: {}, scoring URI: {}\".format(name, webservice.scoring_uri))"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1102,6 +1128,11 @@
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"authors": [
|
||||
{
|
||||
"name": "minxia"
|
||||
}
|
||||
],
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.6",
|
||||
"language": "python",
|
||||
|
||||
@@ -64,7 +64,7 @@ init = tf.global_variables_initializer()
|
||||
saver = tf.train.Saver()
|
||||
|
||||
# start an Azure ML run
|
||||
run = Run.get_submitted_run()
|
||||
run = Run.get_context()
|
||||
|
||||
with tf.Session() as sess:
|
||||
init.run()
|
||||
|
||||
Reference in New Issue
Block a user