How timgaripov/dnn-mode-connectivity works
Main Components
• Data Preprocessing & Loading: Represented by the data.py file and parts of train.py and eval_curve.py that handle dataset selection, transformations, and loading (with dependency on torchvision).
• Curve Finding Module: This is the core of the mode connectivity approach. Key scripts like curves.py, connect.py, and test_curve.py are responsible for finding and testing the curves that connect two endpoints in the loss landscape.
• Training Pipeline: The train.py script orchestrates training for both endpoints and curves. Illustrate this as a main “Training Engine” that interacts with the Data Loader, Model Components, and Curve Finding Module.
• Fast Geometric Ensembling (FGE): Represented by fge.py and further supported by eval_ensemble.py. This component takes a pre-trained checkpoint and, using a cyclical learning rate schedule, generates an ensemble of models for better generalization.
• Evaluation & Visualization: The eval_curve.py script evaluates the loss and accuracy along the curves, and plane.py along with plane_plot.py likely helps with visualization of loss surfaces. This can be depicted as a separate “Evaluation & Visualization” module.
• Utilities: The utils.py script and any helper functions are used across modules (data processing, parameter logging, checkpoint management, etc.) and should be shown as supporting components.
Relationships and Interactions
• Model Checkpoints: Show that train.py produces checkpoints which are then used in further modules:
• For training curves with curves.py (and connect.py) which uses two endpoint checkpoints.
• For FGE (fge.py), where a pre-trained checkpoint is used to initialize the ensembling process.
• For evaluation (eval_curve.py and eval_ensemble.py) where saved checkpoints are loaded to compute loss, accuracy trends, and generate statistics (possibly saved in npz files).
• External Dependencies: Indicate that PyTorch, torchvision, and tabulate are underlying frameworks/libraries essential to the implementation. These should be drawn as external resources that feed into the Training Pipeline and Model Components.
Architectural Patterns and Design Principles
• “Processing/Execution Scripts” (train.py, fge.py, eval_curve.py)
• “Model Architecture Modules” (contents of the models/ directory)
• “Supporting Modules” (data.py, curves.py, utils.py, etc.)
• Checkpoint & Workflow Structure: Emphasize how checkpoints are central to the process flow, especially when transitioning between training endpoints, curve training, and FGE.
• Parameterization & Experimentation: Note that numerous parameters (learning rate, epochs, weight decay, curve type, number of bends) are passed around through the scripts, suggesting a design that supports experiment configuration externally (via CLI arguments).