Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Automatic Hyperparameter Tuning | Conclusion
Introduction to Neural Networks

Svep för att visa menyn

book
Challenge: Automatic Hyperparameter Tuning

Rather than manually selecting specific values for our model's hyperparameters, randomized search (RandomizedSearchCV) offers a more efficient way to find an optimal configuration. Unlike grid search (GridSearchCV), which systematically evaluates all possible combinations of hyperparameters, randomized search selects a random subset of these combinations. This approach significantly reduces computational cost while still yielding strong results.

For neural networks, where the number of possible hyperparameter combinations can be immense, exhaustively testing every option is often impractical. Randomized search circumvents this issue by randomly sampling a defined number of hyperparameter sets, balancing exploration and efficiency.

python
  • estimator: the model to optimize (e.g., MLPClassifier);

  • param_distributions: a dictionary where keys are hyperparameter names and values are lists which to sample;

  • n_iter: specifies how many random combinations should be tested. A higher value increases the chances of finding an optimal combination but requires more computation;

  • scoring: defines the evaluation metric (e.g., 'accuracy' for classification).

Uppgift

Swipe to start coding

  1. In param_distributions, generate values for two hidden layers, where each layer has the same number of neurons, ranging from 20 to 30 (inclusive) with a step of 2.
  2. In param_distributions, set the learning rate values to 0.02, 0.01, and 0.005.
  3. In param_distributions, generate 10 random values for the number of training epochs, ensuring they are within the range 10 to 50 (exclusive).
  4. Apply randomized search with 4 iterations (number of hyperparameter combinations to evaluate) and use accuracy as the evaluation metric.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 3

Fråga AI

expand
ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

book
Challenge: Automatic Hyperparameter Tuning

Rather than manually selecting specific values for our model's hyperparameters, randomized search (RandomizedSearchCV) offers a more efficient way to find an optimal configuration. Unlike grid search (GridSearchCV), which systematically evaluates all possible combinations of hyperparameters, randomized search selects a random subset of these combinations. This approach significantly reduces computational cost while still yielding strong results.

For neural networks, where the number of possible hyperparameter combinations can be immense, exhaustively testing every option is often impractical. Randomized search circumvents this issue by randomly sampling a defined number of hyperparameter sets, balancing exploration and efficiency.

python
  • estimator: the model to optimize (e.g., MLPClassifier);

  • param_distributions: a dictionary where keys are hyperparameter names and values are lists which to sample;

  • n_iter: specifies how many random combinations should be tested. A higher value increases the chances of finding an optimal combination but requires more computation;

  • scoring: defines the evaluation metric (e.g., 'accuracy' for classification).

Uppgift

Swipe to start coding

  1. In param_distributions, generate values for two hidden layers, where each layer has the same number of neurons, ranging from 20 to 30 (inclusive) with a step of 2.
  2. In param_distributions, set the learning rate values to 0.02, 0.01, and 0.005.
  3. In param_distributions, generate 10 random values for the number of training epochs, ensuring they are within the range 10 to 50 (exclusive).
  4. Apply randomized search with 4 iterations (number of hyperparameter combinations to evaluate) and use accuracy as the evaluation metric.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 3
Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Vi beklagar att något gick fel. Vad hände?
some-alt