This commit is contained in:
PatrickBue 2019-09-03 16:04:26 +00:00 коммит произвёл GitHub
Родитель 4f9c7b1280
Коммит a78541829b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 25 добавлений и 15 удалений

Просмотреть файл

@ -35,7 +35,7 @@
"* Setup and Run Hyperdrive Experiment\n",
"* Model Import, Re-train and Test\n",
"\n",
"This notebook is very similar to the [24_exploring_hyperparameters_on_azureml.ipynb](../../classification/notebooks/24_exploring_hyperparameters_on_azureml.ipynb) hyperdrive notebook used for image classification."
"This notebook is very similar to the [24_exploring_hyperparameters_on_azureml.ipynb](../../classification/notebooks/24_exploring_hyperparameters_on_azureml.ipynb) hyperdrive notebook used for image classification. For key concepts of AzureML see this [tutorial](https://docs.microsoft.com/en-us/azure/machine-learning/service/tutorial-train-models-with-aml?view=azure-ml-py&toc=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpython%2Fapi%2Fazureml_py_toc%2Ftoc.json%3Fview%3Dazure-ml-py&bc=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpython%2Fazureml_py_breadcrumb%2Ftoc.json%3Fview%3Dazure-ml-py) on model training and evaluation."
]
},
{
@ -48,6 +48,7 @@
"import sys\n",
"from distutils.dir_util import copy_tree\n",
"import numpy as np\n",
"import scrapbook as sb\n",
"\n",
"import azureml.core\n",
"from azureml.core import Workspace, Experiment\n",
@ -156,7 +157,7 @@
"### 2. Create Remote Target\n",
"We create a GPU cluster as our remote compute target. If a cluster with the same name already exists in our workspace, the script will load it instead. This [link](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-set-up-training-targets#compute-targets-for-training) provides more information about how to set up a compute target on different locations.\n",
"\n",
"By default, the VM size is set to use STANDARD\\_NC6 machines. However, if quota is available, our recommendation is to use STANDARD\\_NC6S\\_V3 machines which come with the much faster V100 GPU."
"By default, the VM size is set to use STANDARD\\_NC6 machines. However, if quota is available, our recommendation is to use STANDARD\\_NC6S\\_V3 machines which come with the much faster V100 GPU. We set the minimum number of nodes to zero so that the cluster won't incur additional compute charges when not in use."
]
},
{
@ -303,7 +304,7 @@
"print(f\"params = {params}\")\n",
"\n",
"# Getting training and validation data\n",
"path = params['data_dir'] + \"/data/\"\n",
"path = os.path.join(params['data_dir'], \"/data/\")\n",
"data = DetectionDataset(path, train_pct=0.5, batch_size = params[\"batch_size\"])\n",
"print(\n",
" f\"Training dataset: {len(data.train_ds)} | Training DataLoader: {data.train_dl} \\n \\\n",
@ -365,8 +366,7 @@
"metadata": {},
"outputs": [],
"source": [
"experiment_name = 'hyperparameter-tuning'\n",
"exp = Experiment(workspace=ws, name=experiment_name)"
"exp = Experiment(workspace=ws, name='hyperparameter-tuning')"
]
},
{
@ -391,9 +391,7 @@
" '--learning_rate': choice(LEARNING_RATES),\n",
" '--max_size': choice(IM_MAX_SIZES)\n",
" }\n",
")\n",
"early_termination_policy = None\n",
"max_total_runs = None # Set to none to run all possible grid parameter combinations"
")"
]
},
{
@ -436,13 +434,15 @@
"metadata": {},
"outputs": [],
"source": [
"hyperdrive_run_config = HyperDriveConfig(estimator=est,\n",
" hyperparameter_sampling=param_sampling,\n",
" policy=early_termination_policy,\n",
" primary_metric_name='accuracy',\n",
" primary_metric_goal=PrimaryMetricGoal.MAXIMIZE,\n",
" max_total_runs=max_total_runs,\n",
" max_concurrent_runs=MAX_NODES)"
"hyperdrive_run_config = HyperDriveConfig(\n",
" estimator=est,\n",
" hyperparameter_sampling=param_sampling,\n",
" policy=None, # Do not use any early termination \n",
" primary_metric_name='accuracy',\n",
" primary_metric_goal=PrimaryMetricGoal.MAXIMIZE,\n",
" max_total_runs=None # Set to none to run all possible grid parameter combinations,\n",
" max_concurrent_runs=MAX_NODES\n",
")"
]
},
{
@ -592,6 +592,16 @@
"\n",
"To avoid unnecessary expenses, all resources which were created in this notebook need to get deleted once parameter search is concluded. To simplify this clean-up step, we recommended creating a new resource group to run this notebook. This resource group can then be deleted, e.g. using the Azure Portal, which will remove all created resources."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Log some outputs using scrapbook which are used during testing to verify correct notebook execution\n",
"sb.glue(\"best_accuracy\", best_run_metrics['accuracy'])"
]
}
],
"metadata": {