Skip to content

Commit

Permalink
Refinements to work better on the platform
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean Wampler committed Jul 21, 2020
1 parent 8d1efe4 commit 7a8f5fa
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
9 changes: 6 additions & 3 deletions ray-tune/01-Understanding-Hyperparameter-Tuning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@
"\n",
"The next cell runs Tune for this purpose. The comments explain what each argument does. We'll do four tries, one for each combination of the two possible values for the two hidden layers.\n",
"\n",
"> **Note:** `tune.run` will handle Ray initialization for us, if it isn't already initialized. To force Tune to throw an error instead, pass the argument `ray_auto_init=False`."
"> **Note:** `tune.run` will handle Ray initialization for us, if it isn't already initialized. To force Tune to throw an error instead, pass the argument `ray_auto_init=False`.\n",
"\n",
"The next cell will take 5-6 minutes to run."
]
},
{
Expand All @@ -187,7 +189,8 @@
" config={\n",
" \"env\": \"CartPole-v1\", # Tune can associate this string with the environment.\n",
" \"num_gpus\": 0, # If you have GPUs, go for it!\n",
" \"num_workers\": 6, # Number of Ray workers to use (arbitrary choice).\n",
" \"num_workers\": 3, # Number of Ray workers to use; Use one LESS than \n",
" # the number of cores you wan to use (or omit this argument)!\n",
" \"model\": { # The NN model we'll optimize.\n",
" 'fcnet_hiddens': [ # \"Fully-connected network with N hidden layers\".\n",
" tune.grid_search([20, 40]), # Try these four values for layer one.\n",
Expand Down Expand Up @@ -277,7 +280,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We see from this table that the `[20,20]` hyperparameter set took the *most* training iterations, which is understandable as it is the least powerful network configuration. The corresponding number of timesteps was the longest. In contrast, `[40,40]` was the fastest to train with almost the same `episode_reward_mean` value.\n",
"We see from this table that the `[20,20]` hyperparameter set took the *most* training iterations, which is understandable as it is the least powerful network configuration. The corresponding number of timesteps was the longest. In contrast, `[40,20]` and `[40,40]` are the fastest to train with almost the same `episode_reward_mean` value.\n",
"\n",
"Since all four combinations perform equally well, perhaps it's best to choose the largest network as it trains the fastest. If we need to train the neural network frequently, then fast training times might be most important. This also suggests that we should be sure the trial sizes we used are really best. In a real-world application, you would want to spend more time on HPO, trying a larger set of possible values."
]
Expand Down
2 changes: 1 addition & 1 deletion ray-tune/02-Ray-Tune-with-MNIST.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
"\n",
"We'll try both, starting with the functional API.\n",
"\n",
"We add a stopping criterion, `stop={\"training_iteration\": 10}`, so this will go quickly. Consider removing this condition if you don't mind waiting."
"We add a stopping criterion, `stop={\"training_iteration\": 20}`, so this will go reasonably quickly, while still producing good results. Consider removing this condition if you don't mind waiting longer and you want optimal results."
]
},
{
Expand Down
17 changes: 17 additions & 0 deletions ray-tune/03-Search-Algos-and-Schedulers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@
"A limitation of search algorithms used by themselves is they can't affect or stop training processes, for example early stopping of trail that are performing poorly. The schedulers can do this, so it's common to use a compatible search algorithm with a scheduler, as we'll show in the first example."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Python 3.7.6\n"
]
}
],
"source": [
"!python --version"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
1 change: 0 additions & 1 deletion ray-tune/04-Ray-SGD.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
" data_creator=data_creator,\n",
" optimizer_creator=optimizer_creator,\n",
" loss_creator=torch.nn.MSELoss,\n",
" num_workers=2,\n",
" use_gpu=False,\n",
" config={\"batch_size\": 64})"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
" config={\n",
" \"env\": \"CartPole-v1\",\n",
" \"num_gpus\": 0,\n",
" \"num_workers\": 6,\n",
" \"num_workers\": 3,\n",
" \"model\": {\n",
" 'fcnet_hiddens': [\n",
" tune.grid_search(sizes),\n",
Expand Down

0 comments on commit 7a8f5fa

Please sign in to comment.