Complete Optimization Example
Here’s a full optimization script that you can use as a starting point:Defining Search Spaces
Search spaces dictate the possible values that a given hyperparameter can be given for an individual model optimization trial. There are three ways to define a search space:| Type | Syntax | Description |
|---|---|---|
Fixed | param=2 | Lock a parameter to a single value |
Select | param={"select": [2, 4, 6, 8]} | Choose from a discrete list of values |
Range | param={"range": [2, 5, 1]} | Choose from a range of [start, end, step] |
Fixed Values
Lock a parameter to a single value:Select (Discrete Options)
Choose from a list of values:Range (Numeric Intervals)
Specify a range with[start, end, step]:
Range is only supported for numeric parameters. Use
select for strings and booleans.Model Optimization Configs
Model optimization configs (eg.MLPOptConfig, RNNOptConfig, TransformerOptConfig) are identical to their regular model config counterparts, but allow for parameter search spaces.
They use the same model inputs and outputs as regular model configs, which makes it easy to jump between training individual models and optimizing models — see the Training Models tutorial for details on defining inputs/outputs.
After optimization, you will still load the resulting models using their regular model configs, Opt configs are only used to configure the optimization.
MLP (MLPOptConfig)
Best for systems with relatively simple dynamics or for fast inference:
RNN (RNNOptConfig)
Better for systems with complex temporal dependencies:
Transformer (TransformerOptConfig)
Powerful for capturing long-range dependencies:
Optimizer Configs
AdamW (AdamWOptConfig) (recommended for most cases):
SGDOptConfig):
Learning Rate Scheduler Configs
Cosine Decay with Warmup (CosineDecayWithWarmupOptConfig):
CosineAnnealingWarmRestartsOptConfig):
None in your scheduler list to try training without a scheduler:
OptimizationConfig
TheOptimizationConfig is used to bring together your search spaces for hyperparameters.
Note that for models, optimizers, and learning rate schedulers, you pass in lists of Opt configs. This is effectively a high-level Select search space, so you can optimize across different model architectures, optimizers, and learning rate schedulers.
While you have lots of flexibility in defining search spaces, we recommend starting with a baseline like the example at the top of this page and then narrowing down to the most promising configurations.
Running Optimization
Loading Optimized Models
As optimization trials complete, each trial will result in a new trained model version. You can load these model versions the same way you load individually trained models - see the Training Models tutorial for more details on loading models, including offline mode and local caching.Next Steps
Simulating with Models
Deploy your optimized models for simulation