src.canns.models.basic.cann¶
Classes¶
Base class for Continuous Attractor Neural Network (CANN) models. |
|
Base class for 1D Continuous Attractor Neural Network (CANN) models. |
|
Base class for 2D Continuous Attractor Neural Network (CANN) models. |
|
A standard 1D Continuous Attractor Neural Network (CANN) model. |
|
A 1D CANN model that incorporates Spike-Frequency Adaptation (SFA). |
|
A 2D Continuous Attractor Neural Network (CANN) model. |
|
A 2D Continuous Attractor Neural Network (CANN) model with a specific |
Module Contents¶
- class src.canns.models.basic.cann.BaseCANN(shape, **kwargs)[source]¶
Bases:
src.canns.models.basic._base.BasicModelBase class for Continuous Attractor Neural Network (CANN) models. This class sets up the fundamental properties of the network, including neuronal properties, feature space, and the connectivity matrix, which are shared by different CANN model variations.
Initializes the base CANN model.
- Parameters:
shape (int or tuple) – The number of neurons in the network. If an int is provided, it will be converted to a single-element tuple. If a tuple is provided, it defines the shape of the network (e.g., (length, length) for 2D). Internally, shape is always stored as a tuple.
**kwargs – Additional keyword arguments passed to the parent BasicModel.
- abstractmethod get_stimulus_by_pos(pos)[source]¶
Generates an external stimulus based on a given position in the feature space. This method should be implemented in subclasses to define how the stimulus is shaped.
- Parameters:
pos (float or Array) – The position in the feature space where the stimulus is centered.
- Returns:
An array of stimulus values for each neuron.
- Return type:
Array
- abstractmethod make_conn()[source]¶
Constructs the connectivity matrix for the CANN model. This method should be implemented in subclasses to define how neurons are connected based on their feature preferences.
- Returns:
A connectivity matrix defining the synaptic strengths between neurons.
- Return type:
Array
- class src.canns.models.basic.cann.BaseCANN1D(num, tau=1.0, k=8.1, a=0.5, A=10, J0=4.0, z_min=-bm.pi, z_max=bm.pi, **kwargs)[source]¶
Bases:
BaseCANNBase class for 1D Continuous Attractor Neural Network (CANN) models. This class sets up the fundamental properties of the network, including neuronal properties, feature space, and the connectivity matrix, which are shared by different CANN model variations.
Initializes the base 1D CANN model.
- Parameters:
num (int) – The number of neurons in the network.
tau (float) – The synaptic time constant, controlling how quickly the membrane potential changes.
k (float) – A parameter controlling the strength of the global inhibition.
a (float) – The half-width of the excitatory connection range. It defines the “spread” of local connections.
A (float) – The magnitude (amplitude) of the external stimulus.
J0 (float) – The maximum connection strength between neurons.
z_min (float) – The minimum value of the feature space (e.g., -pi for an angle).
z_max (float) – The maximum value of the feature space (e.g., +pi for an angle).
**kwargs – Additional keyword arguments passed to the parent BasicModel.
- dist(d)[source]¶
Calculates the shortest distance between two points in a circular feature space with periodic boundary conditions.
- Parameters:
d (Array) – The difference between two positions.
- Returns:
The shortest distance, wrapped around the periodic boundary.
- Return type:
Array
- get_stimulus_by_pos(pos)[source]¶
Generates a Gaussian-shaped external stimulus centered at a given position.
- Parameters:
pos (float) – The center position of the stimulus in the feature space.
- Returns:
An array of stimulus values for each neuron.
- Return type:
Array
- class src.canns.models.basic.cann.BaseCANN2D(length, tau=1.0, k=8.1, a=0.5, A=10, J0=4.0, z_min=-bm.pi, z_max=bm.pi, **kwargs)[source]¶
Bases:
BaseCANNBase class for 2D Continuous Attractor Neural Network (CANN) models. This class sets up the fundamental properties of the network, including neuronal properties, feature space, and the connectivity matrix, which are shared by different CANN model variations.
Initializes the base 2D CANN model.
- Parameters:
length (int) – The number of neurons in one dimension of the network (the network is square).
tau (float) – The synaptic time constant, controlling how quickly the membrane potential changes.
k (float) – A parameter controlling the strength of the global inhibition.
a (float) – The half-width of the excitatory connection range. It defines the “spread” of local connections.
A (float) – The magnitude (amplitude) of the external stimulus.
J0 (float) – The maximum connection strength between neurons.
z_min (float) – The minimum value of the feature space (e.g., -pi for an angle).
z_max (float) – The maximum value of the feature space (e.g., +pi for an angle).
**kwargs – Additional keyword arguments passed to the parent BasicModel.
- dist(d)[source]¶
Calculates the shortest distance vector between two points in a 2D feature space with periodic boundary conditions (a torus).
- Parameters:
d (Array) – The difference vector between two positions, e.g., [dx, dy].
- Returns:
- The shortest distance vector, with each component wrapped around
the periodic boundary.
- Return type:
Array
- get_stimulus_by_pos(pos)[source]¶
Generates a Gaussian-shaped external stimulus centered at a given coordinate on the 2D neural grid.
- Parameters:
pos (Array, tuple) – The center coordinate [x, y] of the stimulus in the feature space.
- Returns:
A 2D array (grid) of stimulus values for each neuron.
- Return type:
Array
- make_conn()[source]¶
Constructs the connectivity matrix for a 2D grid of neurons based on a Gaussian profile. The connection strength between two neurons depends on the Euclidean distance between their preferred feature coordinates in a 2D toroidal space (space with periodic boundaries in both dimensions).
- Returns:
A ((num*num) x (num*num)) connectivity matrix.
- Return type:
Array
- class src.canns.models.basic.cann.CANN1D(*args, **kwargs)[source]¶
Bases:
BaseCANN1DA standard 1D Continuous Attractor Neural Network (CANN) model. This model implements the core dynamics where a localized “bump” of activity can be sustained and moved by external inputs.
- Reference:
Wu, S., Hamaguchi, K., & Amari, S. I. (2008). Dynamics and computation of continuous attractors. Neural computation, 20(4), 994-1025.
Initializes the 1D CANN model.
- Parameters:
BaseCANN1D) ((Parameters are inherited from)
- class src.canns.models.basic.cann.CANN1D_SFA(num, tau=1.0, tau_v=50.0, k=8.1, a=0.3, A=0.2, J0=1.0, z_min=-bm.pi, z_max=bm.pi, m=0.3, **kwargs)[source]¶
Bases:
BaseCANN1DA 1D CANN model that incorporates Spike-Frequency Adaptation (SFA). SFA is a slow negative feedback mechanism that causes neurons to fire less over time for a sustained input, which can induce anticipative tracking behavior.
- Reference:
Mi, Y., Fung, C. C., Wong, K. Y., & Wu, S. (2014). Spike frequency adaptation implements anticipative tracking in continuous attractor neural networks. Advances in neural information processing systems, 27.
Initializes the 1D CANN model with SFA.
- Parameters:
- class src.canns.models.basic.cann.CANN2D(*args, **kwargs)[source]¶
Bases:
BaseCANN2DA 2D Continuous Attractor Neural Network (CANN) model. This model extends the base CANN2D class to include specific dynamics and properties for a 2D neural network.
- Reference:
Wu, S., Hamaguchi, K., & Amari, S. I. (2008). Dynamics and computation of continuous attractors. Neural computation, 20(4), 994-1025.
Initializes the 2D CANN model.
- Parameters:
BaseCANN2D) ((Parameters are inherited from)
- class src.canns.models.basic.cann.CANN2D_SFA(length, tau=1.0, tau_v=50.0, k=8.1, a=0.3, A=0.2, J0=1.0, z_min=-bm.pi, z_max=bm.pi, m=0.3, **kwargs)[source]¶
Bases:
BaseCANN2DA 2D Continuous Attractor Neural Network (CANN) model with a specific implementation of the Synaptic Firing Activity (SFA) dynamics. This model extends the base CANN2D class to include SFA-specific dynamics.
Initializes the 2D CANN model with SFA dynamics.