How dequanwang/tent works
Main components of the system
• Experiment Runner: The central script (cifar10c.py) that manages the experiment process by reading command-line configurations.
• Configuration Management: The configuration files within the “cfgs” directory (source.yaml, norm.yaml, tent.yaml) along with conf.py, which likely handle experiment parameters and settings using tools like yacs.
• Adaptation Modules: Three key modules are implemented—tent.py for the entropy minimization-based adaptation, norm.py for test-time normalization updates, and the baseline/source implementation directly in cifar10c.py.
• Underlying Framework: PyTorch is the main dependency, and the design is built around leveraging pre-trained models and datasets (e.g., CIFAR-10-C via RobustBench).
• External Dependencies: The project depends on several libraries (e.g., PyTorch, RobustBench, yacs) and optionally interacts with tools for experiment tracking (as referenced by the wandb report).
Establish the relationships and interactions
• Data Flow: Inputs (images from CIFAR-10-C, possibly adversarial examples) enter through the experiment runner, which loads and configures a PyTorch model.
• Method Selection: Based on the provided configuration file (source, norm, or tent), the system dynamically selects the adaptation method.
• Adaptation Process: The chosen module (tent.py for entropy minimization adaptation or norm.py for normalization updates) processes the input data in an online fashion—making one update per batch to adapt the model.
• Output: The final predictions are produced while also updating model parameters online. Results are compared using performance metrics (error percentages across various corruption types).
Architectural patterns and design principles
• Modularity: Different adaptation strategies (source baseline, normalization, and Tent) are isolated into separate modules/files, which encourages extensibility and clear separation of concerns.
• Configuration-Driven Behavior: With multiple YAML config files, the experiments become highly configurable and demonstrate an inversion of control design—parameters for the experiments are externalized.
• Pipeline Organization: The design emphasizes an experimental pipeline—from data input, through model configuration and adaptation, to final output and evaluation.
• Dependency Management: The system relies on standard Python tools and libraries, ensuring that the adaptation process is reproducible and extensible.