VanillaESTrainer¶
Vanilla Evolution Strategy trainer with full-rank Gaussian perturbations.
VanillaESTrainer ¶
VanillaESTrainer(params, model, fitness_fn, population_size=50, learning_rate=0.01, sigma=0.1, device=None, seed=None)
Bases: ESTrainer
Vanilla Evolution Strategy trainer using Gaussian perturbations and fitness-weighted updates.
This is a basic implementation that can be used as a reference for creating more sophisticated ES algorithms.
Source code in eggroll_trainer/base.py
Functions¶
compute_update ¶
Compute fitness-weighted update.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
perturbations
|
Tensor
|
Tensor of shape (population_size, param_dim) |
required |
fitnesses
|
Tensor
|
Tensor of shape (population_size,) with fitness scores |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Tensor of shape (param_dim,) with parameter update |
Source code in eggroll_trainer/vanilla.py
sample_perturbations ¶
Sample Gaussian perturbations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
population_size
|
int
|
Number of perturbations to sample |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Tensor of shape (population_size, param_dim) with Gaussian noise |
Source code in eggroll_trainer/vanilla.py
Usage¶
from eggroll_trainer import VanillaESTrainer
trainer = VanillaESTrainer(
model.parameters(),
model=model,
fitness_fn=fitness_fn,
population_size=50,
learning_rate=0.01,
sigma=0.1,
seed=42,
)
trainer.train(num_generations=100)
When to Use¶
- Small models (< 10K parameters)
- Understanding ES basics
- Baseline comparisons
Characteristics¶
- ✅ Simple and straightforward
- ✅ Good for small models
- ❌ Memory intensive for large models
- ❌ Slower than EGGROLL for matrix parameters
See Also¶
- EGGROLLTrainer - Recommended for most use cases
- User Guide - Detailed usage guide