DynVision models the dynamics of neural activity using continuous-time differential equations. This approach aims to capture the temporal properties of biological neural networks more accurately than discrete-time recurrent models.
The core of DynVision's dynamics is the following differential equation:
This equation is solved numerically using one of the available solvers in DynVision.
DynVision provides two main solvers for the neural dynamics equation:
The Euler method is a first-order numerical procedure for solving ordinary differential equations (ODEs). It provides a simple approximation:
Advantages:
- Computational efficiency
- Memory efficiency
- Stable for small time steps
Limitations:
- Less accurate for rapidly changing dynamics
- Requires small time steps for stability
The 4th-order Runge-Kutta (RK4) method provides a more accurate approximation for the ODE:
Advantages:
- Higher accuracy than Euler method
- Stable for larger time steps
- Better captures complex dynamics
Limitations:
- Computationally more expensive
- Higher memory requirements
Both solvers use the following parameters to control the dynamics:
The time step dt determines the granularity of the numerical integration. Smaller values provide more accurate solutions but require more computation.
Typical values: 1-5 ms
The time constant tau controls how quickly the neural activity responds to input. Larger values result in slower dynamics.
Typical values: 5-20 ms
DynVision implements separate delays for different types of connections:
t_feedforward: Delay for feedforward connections (default: 10 ms)t_recurrence: Delay for recurrent connections (default: 6 ms)
The dynamics solvers are used in conjunction with recurrent connections to evolve the neural activity over time.
In the DyRCNNx4 model, each layer has its own dynamics solver:
self.tau_V1 = torch.nn.Parameter(
torch.tensor(self.tau, dtype=float),
requires_grad=False,
)
self.tstep_V1 = EulerStep(dt=self.dt, tau=self.tau_V1)
# ... similar for other layersDuring forward propagation, the dynamics solver is applied to the layer's activity:
# Inside the forward method
if operation == "tstep" and hasattr(self, module_name):
module = getattr(self, module_name)
h = layer.get_hidden_state(-1)
x = module(x, h)Numerical stability is a concern when using dynamics solvers, especially with nonlinear activation functions or supralinear transformations. DynVision implements stability checks that can be enabled:
model = DyRCNNx4(
stability_check=True,
# other parameters
)When enabled, the solver will check for NaN or infinite values and raise an error if detected.
Most RCNN models in the literature use discrete-time approaches, where recurrence is unrolled for a fixed number of steps. DynVision's continuous-time approach offers several advantages:
- Biological Plausibility: Neural dynamics in the brain operate in continuous time.
- Temporal Resolution: Allows for fine-grained control over temporal dynamics.
- Flexibility: Different connection types can have different delays.
- Realistic Response Properties: Can better capture phenomena like adaptation and subadditive temporal summation.
You can implement custom dynamics equations by subclassing BaseSolver:
class CustomSolver(BaseSolver):
def forward(self, x, h=None):
# Implement your custom dynamics equation
passDifferent layers can have different time constants:
model = DyRCNNx4(
tau=10.0, # Default time constant
# other parameters
)
# After initialization, modify specific layer time constants
model.tau_V1.data.fill_(5.0)
model.tau_V2.data.fill_(8.0)
model.tau_V4.data.fill_(12.0)
model.tau_IT.data.fill_(15.0)The dynamics solvers add computational overhead to the model, especially when using small time steps or complex solvers like RK4. Consider the following to optimize performance:
- Use Euler for faster computation: The Euler method is often sufficient and much faster.
- Consider training with shorter sequences: During training, shorter sequences can be used.
- Use mixed precision: Enable mixed precision training for better performance.
The dynamics solvers enable DynVision to capture several important biological phenomena:
- Response Latency: Different layers show different response latencies.
- Adaptation: Neural responses decrease with sustained stimulation.
- Subadditive Temporal Summation: Responses to longer stimuli saturate.
- Contrast-Dependent Dynamics: Responses to high-contrast stimuli are faster.
- Short-Term Memory: Recurrent connections allow information persistence.
For more details on the mathematical foundations of these solvers:
- Butcher, J. C. (2016). Numerical methods for ordinary differential equations.
- Heeger, D. J., & Mackey, W. E. (2019). Oscillatory recurrent gated neural integrator circuits (ORGaNICs), a unifying theoretical framework for neural dynamics.
- Soo, W. W., et al. (2024). Recurrent neural network dynamical systems for biological vision.
