How edwinkim3069/warp-cifsl works
Project type and purpose
• This is a research‐oriented Python codebase implementing “Warping the Space: Weight Space Rotation (WaRP) for Class‐Incremental Few‐Shot Learning.”
• It provides data indexing, dataloaders, model definitions, training scripts, and experiment orchestration for sequential few‐shot learning on CIFAR100, MiniImagenet, and CUB200.
File structure
• Top‐level:
• data/ — raw datasets plus session‐specific index lists
• dataloader/ — dataset wrappers and custom sampler
• models/ — network architectures, base trainer, weight‐rotation modules
• script/ — shell scripts for end‐to‐end runs
• train.py — main training entrypoint (pretraining & incremental sessions)
• utils.py — miscellaneous helpers
• LICENSE, README.md
• Patterns:
• Modular separation: data ingestion, model logic, training orchestration
• Trainer abstraction in models/base/fscil_trainer.py
• Configuration via command‐line flags in train.py and bash scripts
README for additional insights
• Describes workflow: automatic download for CIFAR100, manual download + extraction for others
• Two phases:
a) Pretraining on base classes
b) Incremental sessions with WaRP or prototype baseline
• Checkpoints are stored under a “checkpoint/…” structure and loaded as input to incremental runs
a. Main components
1. Data Storage
– “data/” directory holding raw images and session index files
2. Data Loader Layer
– dataloader/data_utils.py: reads index lists & raw files
– dataloader/*/*.py: Dataset subclasses for each benchmark
– dataloader/sampler.py: custom sampler for few‐shot batches
3. Model Layer
– models/base: Network, Trainer abstraction, helper routines
– models/resnet*_*.py, rotated_modules.py, switch_module.py: core architectures & WaRP logic
4. Training Orchestrator
– train.py: CLI interface handling pretrain vs. incremental mode, argument parsing
– script/*.sh: bash wrappers invoking train.py with dataset‐specific flags
5. Checkpoint & Logging
– checkpoint/… folder (created at runtime) storing model .pth files per session
6. External Services
– PyTorch, torchvision
– gdown for Google Drive downloads
– Shell environment (bash)
b. Relationships & data flow
1. Scripts kick off train.py
2. train.py invokes Data Loader Layer → yields DataLoader objects
3. DataLoader feeds batches to Model Layer
4. Model Layer (via fscil_trainer) runs forward/backward, applying WaRP transformations
5. Trainer writes checkpoints to disk; optional logs to stdout or TensorBoard
6. Subsequent incremental sessions load previous checkpoint, repeat steps 2–5
c. Architectural patterns & design principles
• Modular separation of concerns
• Trainer abstraction for base vs. incremental loops
• Configurable via CLI flags, enabling reproducibility
• Weight‐space rotation encapsulated in dedicated modules
d. Key technologies
• Python 3.x
• PyTorch deep learning framework
• Shell scripting (bash) for experiment pipelines