From 7a8f5facbd9ec671ac89e1f37da2150d64f5b20a Mon Sep 17 00:00:00 2001 From: Dean Wampler Date: Tue, 21 Jul 2020 12:53:33 -0700 Subject: [PATCH] Refinements to work better on the platform --- ...01-Understanding-Hyperparameter-Tuning.ipynb | 9 ++++++--- ray-tune/02-Ray-Tune-with-MNIST.ipynb | 2 +- ray-tune/03-Search-Algos-and-Schedulers.ipynb | 17 +++++++++++++++++ ray-tune/04-Ray-SGD.ipynb | 1 - ...anding-Hyperparameter-Tuning-Solutions.ipynb | 2 +- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ray-tune/01-Understanding-Hyperparameter-Tuning.ipynb b/ray-tune/01-Understanding-Hyperparameter-Tuning.ipynb index 5047d0b..abf3a13 100644 --- a/ray-tune/01-Understanding-Hyperparameter-Tuning.ipynb +++ b/ray-tune/01-Understanding-Hyperparameter-Tuning.ipynb @@ -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." ] }, { @@ -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", @@ -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." ] diff --git a/ray-tune/02-Ray-Tune-with-MNIST.ipynb b/ray-tune/02-Ray-Tune-with-MNIST.ipynb index 702d87e..9c229b7 100644 --- a/ray-tune/02-Ray-Tune-with-MNIST.ipynb +++ b/ray-tune/02-Ray-Tune-with-MNIST.ipynb @@ -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." ] }, { diff --git a/ray-tune/03-Search-Algos-and-Schedulers.ipynb b/ray-tune/03-Search-Algos-and-Schedulers.ipynb index 2340a1f..acf9723 100644 --- a/ray-tune/03-Search-Algos-and-Schedulers.ipynb +++ b/ray-tune/03-Search-Algos-and-Schedulers.ipynb @@ -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": {}, diff --git a/ray-tune/04-Ray-SGD.ipynb b/ray-tune/04-Ray-SGD.ipynb index 41f53ca..d57f02d 100644 --- a/ray-tune/04-Ray-SGD.ipynb +++ b/ray-tune/04-Ray-SGD.ipynb @@ -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})" ] diff --git a/ray-tune/solutions/01-Understanding-Hyperparameter-Tuning-Solutions.ipynb b/ray-tune/solutions/01-Understanding-Hyperparameter-Tuning-Solutions.ipynb index add108b..80e6b52 100644 --- a/ray-tune/solutions/01-Understanding-Hyperparameter-Tuning-Solutions.ipynb +++ b/ray-tune/solutions/01-Understanding-Hyperparameter-Tuning-Solutions.ipynb @@ -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",