file:
hyperparameter_tuning.py
Let's see whether we can improve the performance of our model by tuning the hyperparameters.
This requires the following steps:
- Configure AML workspace
- Upload the data to the default datastore of your workspace
- Define a remote AMLCompute compute target
- Prepare scripts for uploading to compute target
- Define Tensorflow estimator
- Configure HyperDrive run
- Submit job for execution.
First step is to attach to an AML workspace.
If you don't have one yet, you can create one using this documentation.
We recommend storing the information in a config.json file in the root directory of this repository.
We upload the training data so that it can be mounted as remote drives in the aml compute targets.
We are using a Standard_NC6
virtual machine. It is inexpensive and includes a GPU powerful enough for this purpose.
The training script and dependencies have to be available to the job running on the compute target.
HyperDrive works best if we use an Estimator specifically defined for tensorflow models.
Next, we define which hyperparameters to search over, and which strategy to use for searching. Here, we are using RandomParameterSampling
and a BanditPolicy
.
Now everything is good to go.