evox.algorithms.so.es_variants.snes

Module Contents

Classes

SNES

The implementation of the SNES algorithm.

API

class evox.algorithms.so.es_variants.snes.SNES(pop_size: int, center_init: torch.Tensor, sigma: float = 1.0, lrate_mean: float = 1.0, temperature: float = 12.5, weight_type: Literal[recomb, temp] = 'temp', device: torch.device | None = None)[source]

Bases: evox.core.Algorithm

The implementation of the SNES algorithm.

Reference: Natural Evolution Strategies (https://www.jmlr.org/papers/volume15/wierstra14a/wierstra14a.pdf)

This code has been inspired by or utilizes the algorithmic implementation from evosax. More information about evosax can be found at the following URL: GitHub Link: https://github.com/RobertTLange/evosax

Initialization

Initialize the SNES algorithm with the given parameters.

Parameters:
  • pop_size – The size of the population.

  • center_init – The initial center of the population. Must be a 1D tensor.

  • optimizer – The optimizer to use. Defaults to None. Currently, only “adam” or None is supported.

  • lrate_mean – The learning rate for the mean. Defaults to 1.0.

  • sigma – The standard deviation of the noise. Defaults to 1.0.

  • temperature – The temperature of the softmax in computing weights. Defaults to 12.5.

  • weight_type – The type of weights to use. Defaults to “temp”.

  • device – The device to use for the tensors. Defaults to None.

step()[source]

Run one step of the SNES algorithm.

The function will sample a population, evaluate their fitness, and then update the center and standard deviation of the algorithm using the sampled population.

record_step()[source]