π Reference Β· information-oriented
DynVision Organization¶
This reference document explains the core organizational principles and structure of the DynVision toolbox.
Core Principles¶
DynVision is organized around three fundamental principles:
- Modular Architecture: Each component is designed as a self-contained module with clear responsibilities and interfaces.
- Biological Plausibility: The structure reflects the hierarchical and recurrent nature of biological visual systems.
- Experimental Workflow: The organization supports systematic experimentation from data preparation to result analysis.
Component Organization¶
The toolbox is structured into specialized modules, each serving a distinct purpose:
dynvision/
βββ base/ # Core base classes and coordination
βββ model_components/ # Neural building blocks
βββ models/ # Complete architectures
βββ params/ # Parameter management system
βββ data/ # Data management
βββ losses/ # Training objectives
βββ runtime/ # Execution handling
βββ workflow/ # Experiment management
βββ visualization/ # Analysis tools
βββ utils/ # Shared utilities
βββ configs/ # Configuration system
βββ cluster/ # Distributed execution
βββ project_paths.py # Centralized path handling
Module Structure and Purpose¶
Base Module¶
The base module provides the fundamental infrastructure for the entire framework:
Core Base Classes:
__init__.py: Contains the BaseModel class that combines the other base classesdynvision.py: Core forward functionality and temporal dynamicslightning.py: PyTorch Lightning integration and training infrastructurecoordination.py: Device and dtype coordination across model componentsstorage.py: Efficient data buffering and memory managementmonitoring.py: Training monitoring and performance tracking utilities
This module establishes the foundational architecture that all other components build upon.
Model Components Module¶
The model_components module provides the fundamental building blocks for neural networks:
Neural Components:
dynamics_solver.py: Numerical integration methods for neural dynamicsrecurrence.py: Recurrent connection implementationstopographic_recurrence.py: Spatially-constrained recurrent connectionslayer_connections.py: Skip and feedback connectivity patternssupralinearity.py: Nonlinear activation functionsretina.py: Retinal processing components
For details, see Model Components Reference.
Parameters Module¶
The params module implements a comprehensive parameter management system:
-
Parameter Categories:
base_params.py: Base parameter definitions and validationmodel_params.py: Model-specific parameter configurationsdata_params.py: Data processing and loading parameterstraining_params.py: Training procedure parameterstesting_params.py: Evaluation and testing parameterstrainer_params.py: PyTorch Lightning trainer configurationsinit_params.py: Model initialization parameters
-
Organization:
- Centralized parameter validation
- Type checking and constraint enforcement
- Configuration inheritance and composition
Models Module¶
The models module implements complete neural architectures:
-
Core Implementations:
- Research models (DyRCNN)
- Standard architectures (ResNet, AlexNet, CorNetRT, CordsNet)
- Custom architectures
-
Model Organization:
- Each model in a separate file
- Consistent inheritance from base classes
- Standardized configuration interface
Data Module¶
The data module manages all data-related operations:
-
Data Loading with PyTorch:
datasets.py: Dataset implementationsdataloader.py: PyTorch data loaders
-
Data Loading with FFCV:
ffcv_datasets.py: Optimized dataset compressionffcv_dataloader.py: Optimized loading pipelinesffcv_operations.py: FFCV-specific operations
-
Processing Pipeline:
transforms.py: Data transformationsoperations.py: Standard processing operationsget_data.py: Dataset acquisition and management
Losses Module¶
The losses module implements training objectives:
-
Loss Functions:
base_loss.py: Abstract base classescross_entropy_loss.py: Classification lossesactivity_loss.py: Biological activity constraint losses
-
Organization:
- Modular implementation with consistent interfaces
- Configurable parameters and composition support
- Support for multi-objective optimization
Runtime Module¶
The runtime module handles execution:
-
Core Components:
init_model.py: Model initialization procedurestrain_model.py: Training execution routinestest_model.py: Evaluation and testing routines
-
Integration:
- PyTorch Lightning integration
- Experiment tracking and logging
- Resource management and optimization
Workflow Module¶
The workflow system orchestrates experiments through Snakemake:
-
Core Workflows:
snake_data.smk: Data preparation pipelinessnake_runtime.smk: Model execution workflowssnake_visualizations.smk: Analysis and visualizationsnake_experiments.smk: Experiment orchestrationSnakefile: Main workflow coordination
-
Management:
mode_manager.py: config mode coordination- Modular rule definitions and dependency management
- Resource allocation and distributed execution
For usage details, see the Workflows Guide.
Visualization Module¶
The visualization module provides analysis tools:
-
Plot Types:
plot_classifier_responses.py: Model response analysisplot_weight_distributions.py: Weight distribution visualizationplot_adaption.py: Temporal adaptation analysisplot_experiment_outputs.py: Experiment result comparisonplot_confusion_matrix.py: Classification performance analysis
-
Components:
callbacks.py: Runtime visualization callbacks- Specialized plotting functions with consistent interfaces
- Analysis utilities for neural dynamics
Utils Module¶
The utils module provides shared functionality:
-
Utility Categories:
config_utils.py: Configuration loading and validationdata_utils.py: Data manipulation operationsmodel_utils.py: Model construction and managementtorch_utils.py: PyTorch helper functionstype_utils.py: Type checking and validationvisualization_utils.py: Plotting helper functions
-
Organization:
- Function-specific files with clear interfaces
- Consistent error handling and documentation
- Shared type definitions and constants
Configuration Module¶
The configuration system manages all settings:
-
Config Files:
config_defaults.yaml: Base default settingsconfig_data.yaml: Dataset and data processing settingsconfig_experiments.yaml: Experiment parameter definitionsconfig_workflow.yaml: Workflow execution settingsconfig_visualization.yaml: Visualization parametersconfig_modes.yaml: Execution mode configurationsconfig_runtime.yaml: Runtime execution settings
-
Organization:
- Hierarchical structure with inheritance
- Override system for flexible configuration
- Environment-specific adaptations
See the Configuration Reference for details.
Cluster Module¶
The cluster module provides distributed execution capabilities:
-
Execution Infrastructure:
- SLURM integration profiles
- Distributed execution scripts
- Job management utilities
-
Development Tools:
- Remote development setup
- Cluster-specific optimizations
- Resource monitoring
Extension Points¶
DynVision can be extended through several mechanisms:
- New Models: Inherit from base classes in
baseandmodel_components - Custom Components: Add modules following the component interface patterns
- Parameter Sets: Define new parameter configurations in the
paramsmodule - New Experiments: Add specialized workflows in
workflowand parameter sweeps inconfigs - Additional Workflows: Define new Snakemake rules and execution modes
- Visualization Tools: Implement new analysis capabilities in
visualization - Loss Functions: Add new training objectives in the
lossesmodule - Utility Functions: Contribute shared functionality to the
utilsmodule
For implementation details, refer to the Custom Models Guide.