Skip to main content

PcActorConfig

Struct PcActorConfig 

Source
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: usize

Number of input features (e.g. 9 for tic-tac-toe board).

§hidden_layers: Vec<LayerDef>

Hidden layer topology definitions.

§output_size: usize

Number of output actions.

§output_activation: Activation

Activation function for the output layer.

§alpha: f64

Inference 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: f64

Convergence 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: usize

Minimum PC inference steps before convergence check is allowed. Active regardless of residual setting. Default: 1.

§max_steps: usize

Maximum PC inference steps per action. Active regardless of residual setting. Default: 20.

§lr_weights: f64

Base learning rate for weight updates. Default: 0.01.

§synchronous: bool

If true, use synchronous snapshot mode; otherwise in-place. Default: true.

§temperature: f64

Softmax temperature for action selection. Default: 1.0.

§local_lambda: f64

Blend 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: bool

Enable 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: f64

Initial 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

Source§

fn clone(&self) -> PcActorConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PcActorConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PcActorConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for PcActorConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,