pub struct SpikingNeuron {
pub membrane_potential: f64,
pub threshold: f64,
pub refractory_period: f64,
pub time_since_spike: f64,
pub leak_constant: f64,
pub input_current: f64,
pub position: Vec<f64>,
pub learning_rate: f64,
}Expand description
Spiking neuron model using leaky integrate-and-fire dynamics
This neuron model integrates input currents over time and generates spikes when the membrane potential exceeds a threshold. After spiking, the neuron enters a refractory period during which it cannot spike again.
§Model Dynamics
The membrane potential follows the equation: dV/dt = -leak_constant * V + I(t)
Where V is membrane potential and I(t) is input current.
§Example
use scirs2_spatial::neuromorphic::core::SpikingNeuron;
let mut neuron = SpikingNeuron::new(vec![0.0, 0.0]);
// Simulate neuron for several time steps
let dt = 0.1;
let input_current = 1.5;
for _ in 0..20 {
let spiked = neuron.update(dt, input_current);
if spiked {
println!("Neuron spiked!");
}
}Fields§
§membrane_potential: f64Membrane potential
threshold: f64Spike threshold
refractory_period: f64Refractory period
time_since_spike: f64Time since last spike
leak_constant: f64Leak constant
input_current: f64Input current
position: Vec<f64>Neuron position in space
learning_rate: f64Learning rate
Implementations§
Source§impl SpikingNeuron
impl SpikingNeuron
Sourcepub fn with_params(
position: Vec<f64>,
threshold: f64,
refractory_period: f64,
leak_constant: f64,
learning_rate: f64,
) -> Self
pub fn with_params( position: Vec<f64>, threshold: f64, refractory_period: f64, leak_constant: f64, learning_rate: f64, ) -> Self
Create a new spiking neuron with custom parameters
§Arguments
position- Spatial position of the neuronthreshold- Spike thresholdrefractory_period- Duration of refractory periodleak_constant- Membrane leak constantlearning_rate- Learning rate for adaptation
Sourcepub fn calculate_influence(&self, other_position: &[f64]) -> f64
pub fn calculate_influence(&self, other_position: &[f64]) -> f64
Sourcepub fn set_position(&mut self, position: Vec<f64>)
pub fn set_position(&mut self, position: Vec<f64>)
Set neuron position
Sourcepub fn membrane_potential(&self) -> f64
pub fn membrane_potential(&self) -> f64
Get membrane potential
Sourcepub fn set_membrane_potential(&mut self, potential: f64)
pub fn set_membrane_potential(&mut self, potential: f64)
Set membrane potential
Sourcepub fn set_threshold(&mut self, threshold: f64)
pub fn set_threshold(&mut self, threshold: f64)
Set spike threshold
Sourcepub fn refractory_period(&self) -> f64
pub fn refractory_period(&self) -> f64
Get refractory period
Sourcepub fn set_refractory_period(&mut self, period: f64)
pub fn set_refractory_period(&mut self, period: f64)
Set refractory period
Sourcepub fn leak_constant(&self) -> f64
pub fn leak_constant(&self) -> f64
Get leak constant
Sourcepub fn set_leak_constant(&mut self, leak: f64)
pub fn set_leak_constant(&mut self, leak: f64)
Set leak constant
Sourcepub fn learning_rate(&self) -> f64
pub fn learning_rate(&self) -> f64
Get learning rate
Sourcepub fn set_learning_rate(&mut self, rate: f64)
pub fn set_learning_rate(&mut self, rate: f64)
Set learning rate
Sourcepub fn is_refractory(&self) -> bool
pub fn is_refractory(&self) -> bool
Check if neuron is in refractory period
Sourcepub fn time_since_spike(&self) -> f64
pub fn time_since_spike(&self) -> f64
Get time since last spike
Sourcepub fn inject_current(&mut self, current: f64)
pub fn inject_current(&mut self, current: f64)
Inject current into the neuron
Sourcepub fn distance_to(&self, other: &SpikingNeuron) -> Option<f64>
pub fn distance_to(&self, other: &SpikingNeuron) -> Option<f64>
Sourcepub fn adapt_threshold(
&mut self,
target_rate: f64,
actual_rate: f64,
adaptation_rate: f64,
)
pub fn adapt_threshold( &mut self, target_rate: f64, actual_rate: f64, adaptation_rate: f64, )
Adapt threshold based on recent activity (homeostatic plasticity)
§Arguments
target_rate- Target firing rateactual_rate- Actual firing rateadaptation_rate- Rate of threshold adaptation
Sourcepub fn adapt_learning_rate(
&mut self,
performance_factor: f64,
adaptation_rate: f64,
)
pub fn adapt_learning_rate( &mut self, performance_factor: f64, adaptation_rate: f64, )
Update learning rate based on recent performance
§Arguments
performance_factor- Factor indicating learning performance (0-1)adaptation_rate- Rate of learning rate adaptation
Trait Implementations§
Source§impl Clone for SpikingNeuron
impl Clone for SpikingNeuron
Source§fn clone(&self) -> SpikingNeuron
fn clone(&self) -> SpikingNeuron
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SpikingNeuron
impl RefUnwindSafe for SpikingNeuron
impl Send for SpikingNeuron
impl Sync for SpikingNeuron
impl Unpin for SpikingNeuron
impl UnwindSafe for SpikingNeuron
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.