AlignPost#
- class brainpy.mixin.AlignPost[source]#
Mixin for aligning post-synaptic inputs.
This mixin provides an interface for components that need to receive and process post-synaptic inputs, such as synaptic connections or neural populations. The
align_post_input_addmethod should be implemented to handle the accumulation of external currents or inputs.Notes
Classes that inherit from this mixin must implement the
align_post_input_addmethod.Examples
Implementing a synapse with post-synaptic alignment:
>>> import brainstate >>> import jax.numpy as jnp >>> >>> class Synapse(brainstate.mixin.AlignPost): ... def __init__(self, weight): ... self.weight = weight ... self.post_current = brainstate.State(0.0) ... ... def align_post_input_add(self, current): ... # Accumulate the weighted current into post-synaptic target ... self.post_current.value += current * self.weight >>> >>> # Usage >>> synapse = Synapse(weight=0.5) >>> synapse.align_post_input_add(10.0) >>> print(synapse.post_current.value) # Output: 5.0
Using with neural populations:
>>> class NeuronGroup(brainstate.mixin.AlignPost): ... def __init__(self, size): ... self.size = size ... self.input_current = brainstate.State(jnp.zeros(size)) ... ... def align_post_input_add(self, current): ... # Add external current to neurons ... self.input_current.value = self.input_current.value + current >>> >>> neurons = NeuronGroup(100) >>> external_input = jnp.ones(100) * 0.5 >>> neurons.align_post_input_add(external_input)
- align_post_input_add(*args, **kwargs)[source]#
Add external inputs to the post-synaptic component.
- Parameters:
*args – Positional arguments for the input.
**kwargs – Keyword arguments for the input.
- Raises:
NotImplementedError – If the method is not implemented by the subclass.