src.canns.models.basic

Submodules

Classes

CANN1D

A standard 1D Continuous Attractor Neural Network (CANN) model.

CANN1D_SFA

A 1D CANN model that incorporates Spike-Frequency Adaptation (SFA).

CANN2D

A 2D Continuous Attractor Neural Network (CANN) model.

CANN2D_SFA

A 2D Continuous Attractor Neural Network (CANN) model with a specific

HierarchicalNetwork

A full hierarchical network composed of multiple grid modules.

Package Contents

class src.canns.models.basic.CANN1D(num, tau=1.0, k=8.1, a=0.5, A=10, J0=4.0, z_min=-u.math.pi, z_max=u.math.pi, **kwargs)[source]

Bases: BaseCANN1D

A 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 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.

init_state(*args, **kwargs)[source]

Initializes the state variables of the model.

update(inp)[source]

The main update function, defining the dynamics of the network for one time step.

Parameters:

inp (Array) – The external input for the current time step.

class src.canns.models.basic.CANN1D_SFA(num, tau=1.0, tau_v=50.0, k=8.1, a=0.3, A=0.2, J0=1.0, z_min=-u.math.pi, z_max=u.math.pi, m=0.3, **kwargs)[source]

Bases: BaseCANN1D

A 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:
  • tau_v (float) – The time constant for the adaptation variable ‘v’. A larger value means slower adaptation.

  • m (float) – The strength of the adaptation, coupling the membrane potential ‘u’ to the adaptation variable ‘v’.

  • BaseCANN1D) ((Other parameters are inherited from)

init_state(*args, **kwargs)[source]

Initializes the state variables of the model, including the adaptation variable.

update(inp)[source]

The main update function for the SFA model. It includes dynamics for both the membrane potential and the adaptation variable.

Parameters:

inp (Array) – The external input for the current time step.

m = 0.3
tau_v = 50.0
class src.canns.models.basic.CANN2D(length, tau=1.0, k=8.1, a=0.5, A=10, J0=4.0, z_min=-u.math.pi, z_max=u.math.pi, **kwargs)[source]

Bases: BaseCANN2D

A 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 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.

init_state(*args, **kwargs)[source]

Initializes the state variables of the model.

update(inp)[source]

The main update function, defining the dynamics of the network for one time step.

Parameters:

inp (Array) – The external input to the network, which can be a stimulus or other driving force.

class src.canns.models.basic.CANN2D_SFA(length, tau=1.0, tau_v=50.0, k=8.1, a=0.3, A=0.2, J0=1.0, z_min=-u.math.pi, z_max=u.math.pi, m=0.3, **kwargs)[source]

Bases: BaseCANN2D

A 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.

init_state(*args, **kwargs)[source]

Initializes the state variables of the model, including the adaptation variable.

update(inp)[source]

The main update function for the SFA model. It includes dynamics for both the membrane potential and the adaptation variable.

Parameters:

inp (Array) – The external input for the current time step.

m = 0.3
tau_v = 50.0
class src.canns.models.basic.HierarchicalNetwork(num_module, num_place)[source]

Bases: src.canns.models.basic._base.BasicModelGroup

A full hierarchical network composed of multiple grid modules.

This class creates and manages a collection of HierarchicalPathIntegrationModel modules, each with a different grid spacing. By combining the outputs of these modules, the network can represent position unambiguously over a large area. The final output is a population of place cells whose activities are used to decode the animal’s estimated position.

num_module

The number of grid modules in the network.

Type:

int

num_place

The number of place cells in the output layer.

Type:

int

place_center

The center locations of the place cells.

Type:

brainunit.math.ndarray

MEC_model_list

A list containing all the HierarchicalPathIntegrationModel instances.

Type:

list

grid_fr

The firing rates of the grid cell population.

Type:

brainstate.HiddenState

band_x_fr

The firing rates of the x-oriented band cell population.

Type:

brainstate.HiddenState

band_y_fr

The firing rates of the y-oriented band cell population.

Type:

brainstate.HiddenState

place_fr

The firing rates of the place cell population.

Type:

brainstate.HiddenState

decoded_pos

The final decoded 2D position.

Type:

brainstate.State

References

Anonymous Author(s) “Unfolding the Black Box of Recurrent Neural Networks for Path Integration” (under review).

Initializes the HierarchicalNetwork.

Parameters:
  • num_module (int) – The number of grid modules to create.

  • num_place (int) – The number of place cells along one dimension of a square grid.

init_state(*args, **kwargs)[source]

State initialization function.

update(velocity, loc, loc_input_stre=0.0)[source]

Update function of a network.

In this update function, the update functions in children systems are iteratively called.

MEC_model_list = []
num_module
num_place
place_center