Service · Machine Learning · Builds on AIF-C01
Amazon SageMaker automatic model tuning
Pick a search strategy, set ranges and an objective metric, and balance speed, quality and cost.
You know from AI Practitioner
- A hyperparameter is a setting chosen before training. Weights are learned.
- Common ones: learning rate, batch size, epochs and regularization.
- Automatic model tuning runs many training jobs to find good values.
Bayesian
- How it picks
- Learns from past jobs
- Use when
- Few jobs, limited budget
Random
- How it picks
- Independent samples
- Use when
- Many parallel jobs
Grid
- How it picks
- Every categorical combination
- Use when
- A small, exact set
Hyperband
- How it picks
- Stops weak jobs early
- Use when
- Iterative models
| Strategy | How it picks | Use when |
|---|---|---|
| Bayesian | Learns from past jobs | Few jobs, limited budget |
| Random | Independent samples | Many parallel jobs |
| Grid | Every categorical combination | A small, exact set |
| Hyperband | Stops weak jobs early | Iterative models |
1 / 2
Bayesian
- How it picks
- Learns from past jobs
- Use when
- Few jobs, limited budget
Random
- How it picks
- Independent samples
- Use when
- Many parallel jobs
Grid
- How it picks
- Every categorical combination
- Use when
- A small, exact set
| Strategy | How it picks | Use when |
|---|---|---|
| Bayesian | Learns from past jobs | Few jobs, limited budget |
| Random | Independent samples | Many parallel jobs |
| Grid | Every categorical combination | A small, exact set |
2 / 2
Hyperband
- How it picks
- Stops weak jobs early
- Use when
- Iterative models
| Strategy | How it picks | Use when |
|---|---|---|
| Hyperband | Stops weak jobs early | Iterative models |
- 1The tuner starts training jobs with chosen values.
- 2Each job reports the objective metric, read from its logs.
- 3The tuner uses the results to choose the next values, until it reaches the limits.
What it is
A tuning job takes a training job definition, a range for each hyperparameter, an objective metric to maximize or minimize, and limits. It launches training jobs, reads each job’s metric and chooses what to try next. Ranges can be continuous, integer or categorical. For a range that spans orders of magnitude, such as a learning rate from 0.0001 to 0.1, use logarithmic scaling so values are sampled evenly across powers of ten.
What it is
Strategies. Bayesian optimization (the default) learns from earlier results to choose better values, so it needs few jobs, but it learns less when many jobs run at once. Random search samples independently, so you can run many jobs in parallel. Grid search tries every combination, and only works with categorical values. Hyperband stops weak jobs early and gives more resources to strong ones. It needs an iterative algorithm that reports the metric at each step, such as a neural network.
What it is
The objective metric comes from the algorithm: built-in algorithms emit it for you. For your own script, give a metric definition, a name and a regular expression that finds the number in the training logs.
What it is
Limits: the maximum number of training jobs, and the maximum number running in parallel. More parallel jobs finish sooner but give Bayesian search less to learn from, so quality can drop. Early stopping (set to Auto) ends jobs unlikely to beat the best so far. With Hyperband leave it off, because Hyperband has its own. Warm start reuses results from earlier tuning jobs, so a new job begins informed. Cost: you pay for every training job it runs, so the maximum number of jobs times the cost of one job is the ceiling.
Remember
- Strategies: Bayesian (default), random, grid (categorical only) and Hyperband.
- Use logarithmic scaling for ranges that cross orders of magnitude.
- Objective metric: built in, or a regular expression on the logs for your script.
- More parallel jobs: faster, but less learning for Bayesian search.
Remember
- Early stopping and Hyperband save time and cost. Warm start reuses earlier results.
- You pay for every training job. The maximum number of jobs caps the cost.
On the exam
- “Find the best learning rate and batch size automatically” points to SageMaker automatic model tuning.
- “Tune a neural network and stop poor runs early” points to the Hyperband strategy.
- “Try only these exact combinations of categorical values” points to grid search.
- “Run many jobs at once, each independent of the last” points to random search.
In this task · 2.2
- Built-in algorithms for tabular data
- Built-in algorithms: clustering, dimensionality reduction, anomaly
- Built-in algorithms: text, sequence and forecasting
- Built-in algorithms: image and video
- Training jobs, script mode and ML libraries
SageMaker AMT
- Reducing training time
- Distributed training and HyperPod
- Overfitting, underfitting and catastrophic forgetting
- Combining models
- Epochs, steps, batch size and learning rate
- Task-specific prompt engineering
- Fine-tuning and continued pre-training in Bedrock
- PEFT, LoRA and fine-tuning on SageMaker
- Model distillation
- Optimizing retrieval and embedding models