pyeeg.simulate.CTRNN

class pyeeg.simulate.CTRNN(N, W, input_dim=1, output_dim=1, dt=0.001, seed=42, nonlinearity=<function sigmoid>, theta=None)

Continuous Time Recurrent Neural Network (CTRNN) model.

The state \(x\) of the network evolves according to

\[\tau \dot{x} = -x + W o + I + \theta\]

where \(o = f(x + \theta)\) is the output of the network through the nonlinearity \(f\), \(I\) is the external input projected through a (trainable) input matrix, and \(\theta\) is a bias term. A (trainable) readout matrix projects the node outputs to the desired output dimension, rescaled into the range [-1, 1] when the nonlinearity is a sigmoid.

Parameters:
  • N (int) – The number of neurons/nodes.

  • W (array_like) – The connectivity matrix. Shape (N, N).

  • input_dim (int) – The dimension of the external input. The input is projected through a zero-initialised matrix of shape (N, input_dim).

  • output_dim (int) – The dimension of the readout. The node outputs are projected through a zero-initialised matrix of shape (output_dim, N).

  • dt (float) – The integration time step in seconds.

  • seed (int) – The random seed used to initialise the network’s random number generator.

  • nonlinearity (callable) – The nonlinearity function applied to the network state. Default is sigmoid (e.g. can use np.tanh()).

  • theta (array_like, optional) – The bias term. Shape (N,). If None, a zero bias is used.

Methods

CTRNN.read_out()

Compute the readout of the network.

CTRNN.reset()

Reset the network to its initial state.

CTRNN.simulate([x0, tmax, noise, I])

Simulate the CTRNN model and monitor the output.

CTRNN.step([I, noise])

Compute one step of the CTRNN model.