pub struct ActivationCache<L: LinAlg = CpuLinAlg> { /* private fields */ }Expand description
Cache for hidden layer activations captured during inference.
Used by CCA neuron alignment during crossover to compare functional neuron responses between parent networks. Activations are recorded during normal fitness evaluation at zero additional compute cost.
Generic over a LinAlg backend L. Defaults to CpuLinAlg.
§Examples
use pc_rl_core::pc_actor_critic::ActivationCache;
use pc_rl_core::linalg::cpu::CpuLinAlg;
let cache: ActivationCache<CpuLinAlg> = ActivationCache::new(2);
assert_eq!(cache.batch_size(), 0);
assert_eq!(cache.num_layers(), 2);Implementations§
Source§impl<L: LinAlg> ActivationCache<L>
impl<L: LinAlg> ActivationCache<L>
Sourcepub fn new(num_layers: usize) -> Self
pub fn new(num_layers: usize) -> Self
Creates a new empty cache with the given number of hidden layers.
§Arguments
num_layers- Number of hidden layers to track.
Sourcepub fn batch_size(&self) -> usize
pub fn batch_size(&self) -> usize
Returns the number of samples recorded so far.
Sourcepub fn num_layers(&self) -> usize
pub fn num_layers(&self) -> usize
Returns the number of hidden layers in the cache.
Trait Implementations§
Source§impl<L: Clone + LinAlg> Clone for ActivationCache<L>
impl<L: Clone + LinAlg> Clone for ActivationCache<L>
Source§fn clone(&self) -> ActivationCache<L>
fn clone(&self) -> ActivationCache<L>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<L> Freeze for ActivationCache<L>
impl<L> RefUnwindSafe for ActivationCache<L>
impl<L> Send for ActivationCache<L>
impl<L> Sync for ActivationCache<L>
impl<L> Unpin for ActivationCache<L>
impl<L> UnsafeUnpin for ActivationCache<L>
impl<L> UnwindSafe for ActivationCache<L>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more