pub struct PcActorConfig {Show 14 fields
pub input_size: usize,
pub hidden_layers: Vec<LayerDef>,
pub output_size: usize,
pub output_activation: Activation,
pub alpha: f64,
pub tol: f64,
pub min_steps: usize,
pub max_steps: usize,
pub lr_weights: f64,
pub synchronous: bool,
pub temperature: f64,
pub local_lambda: f64,
pub residual: bool,
pub rezero_init: f64,
}Expand description
Configuration for the predictive coding actor network.
§Examples
use pc_rl_core::activation::Activation;
use pc_rl_core::layer::LayerDef;
use pc_rl_core::pc_actor::PcActorConfig;
let config = PcActorConfig {
input_size: 9,
hidden_layers: vec![LayerDef { size: 18, activation: Activation::Tanh }],
output_size: 9,
output_activation: Activation::Tanh,
alpha: 0.1,
tol: 0.01,
min_steps: 1,
max_steps: 20,
lr_weights: 0.01,
synchronous: true,
temperature: 1.0,
local_lambda: 1.0,
residual: false,
rezero_init: 0.001,
};Fields§
§input_size: usizeNumber of input features (e.g. 9 for tic-tac-toe board).
Hidden layer topology definitions.
output_size: usizeNumber of output actions.
output_activation: ActivationActivation function for the output layer.
alpha: f64Inference learning rate for PC loop state updates (h += alpha * error).
Set to 0.0 to disable PC inference (network behaves as standard MLP).
Active regardless of residual setting. Default: 0.1.
tol: f64Convergence threshold for RMS prediction error.
PC loop exits early when surprise < tol (after at least min_steps).
Active regardless of residual setting. Default: 0.01.
min_steps: usizeMinimum PC inference steps before convergence check is allowed.
Active regardless of residual setting. Default: 1.
max_steps: usizeMaximum PC inference steps per action.
Active regardless of residual setting. Default: 20.
lr_weights: f64Base learning rate for weight updates. Default: 0.01.
synchronous: boolIf true, use synchronous snapshot mode; otherwise in-place. Default: true.
temperature: f64Softmax temperature for action selection. Default: 1.0.
local_lambda: f64Blend factor for hidden layer weight updates, range [0.0, 1.0].
Controls how hidden layers combine two gradient signals:
delta = lambda * backprop_grad + (1 - lambda) * pc_prediction_error
1.0— Pure backprop: reward signal propagated from output (default).0.0— Pure local PC: prediction errors from inference loop used as gradients (Millidge et al. 2022). No vanishing gradient but no reward signal reaches hidden layers.0.0 < lambda < 1.0— Hybrid: reward-aware backprop regularized by local PC consistency errors.
The output layer always uses standard backprop regardless of this value.
residual: boolEnable residual skip connections between same-dimension hidden layers.
When false, rezero_init is ignored. When true, all hidden layers
must have the same size, and skip connections with learnable ReZero
scaling are added between consecutive hidden layers (not the first,
since input_size typically differs from hidden_size).
rezero_init: f64Initial value for ReZero scaling factors on residual connections.
Only used when residual = true. Controls initial contribution of
the nonlinear component: h[i] = rezero_init * tanh(...) + h[i-1].
0.001— Near-identity start (ReZero: network learns depth gradually)1.0— Standard ResNet residual (full contribution from start)
Ignored when residual = false.
Trait Implementations§
Source§impl Clone for PcActorConfig
impl Clone for PcActorConfig
Source§fn clone(&self) -> PcActorConfig
fn clone(&self) -> PcActorConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more