perturbation_utils (macula_tweann v0.18.1)

View Source

Weight perturbation utilities for neural network evolution.

Provides functions for perturbing weights during evolution: - Single weight perturbation with momentum - Batch weight perturbation - Saturation to prevent numerical overflow

Weight Format

Weights use the format: {Weight, DeltaWeight, LearningRate, ParameterList} - Weight: Current synaptic weight value - DeltaWeight: Previous change (for momentum) - LearningRate: Plasticity learning rate - ParameterList: Additional plasticity parameters

Summary

Functions

Perturb a single weight with momentum.

Perturb list of weight specs.

Saturate a value to within +/- limit.

Functions

perturb_weight(_, Spread)

-spec perturb_weight({float(), float(), float(), list()}, float()) ->
                        {float(), float(), float(), list()}.

Perturb a single weight with momentum.

Uses momentum-based perturbation: DW_new = random_noise * spread + DW_old * 0.5 W_new = saturate(W + DW_new)

The 0.5 momentum factor provides smooth weight trajectories during evolution.

perturb_weights(WeightSpecs, Spread)

-spec perturb_weights([{float(), float(), float(), list()}], float()) ->
                         [{float(), float(), float(), list()}].

Perturb list of weight specs.

Applies perturbation to each weight in the list.

sat(Value, Limit)

-spec sat(float(), float()) -> float().

Saturate a value to within +/- limit.

Clamps the value to [-Limit, Limit] to prevent overflow.