How junghwamin/nmfc-plan4-openset-80-100 works
Purpose and entry point
This is a PyTorch research experiment for CIFAR-100 open-set 80/100 transfer. Models train only on 80 deterministic “seen” classes, then evaluate both 100-way reference-bank classification and seen-vs-novel near-OOD detection. Main entry point: python -m src.train --config ...; open-set configs are configs/cifar100_openset.yaml and configs/cifar100_openset_smoke.yaml.
Configuration and experiment orchestration
src/train.py dispatches configured runners, including runner: openset, executes training/evaluation, and caches completed runs using output metrics. src/utils/experiments.py supports experiment lifecycle/output handling. Configs define the two central comparisons: NMFC shrb and a 100-logit softmax baseline.
• src/train.py
• configs/base.yaml
• configs/cifar100_openset.yaml
Open-set data boundary
The image dataset layer selects a deterministic subset of seen class IDs without relabeling them. Training data contains only those examples; test data remains all 100 CIFAR-100 classes, and model class count remains 100. This preserves sparse original labels and creates the principal train/evaluation boundary.
• src/datasets/image.py
• src/datasets/samplers.py
Encoder and model assembly
An ImageNet-pretrained ResNet50-style encoder produces embeddings. src/variants.py interprets the four-axis variant configuration and assembles the NMFC head; the target shrb variant uses softmin energy, hinge-temperature logits, reciprocal APT, and a minibatch bank. Softmax instead uses the conventional linear classifier path.
• src/models/encoders.py
• src/variants.py
• src/models/heads_v3.py
NMFC learning stages
NMFC has a two-phase training control flow: an initial linear-MFA warmup, followed by NMFC loss optimization once the APT controller transitions phases. Core distance/affinity, local energy, softmin neighbor processing, and losses are isolated in src/nmfc, while the head exposes batch training behavior.
• src/nmfc/apt.py
• src/nmfc/losses.py
• src/nmfc/softmin.py
Reference-bank inference
VariantNMFCHead has no class-specific learned classifier weights beyond temperature-related state. After embedding data, it fits class-labeled coreset prototype banks and maps predictions through stored bank_classes. This is the architectural distinction from softmax: replacing an 80-class bank with a 100-class bank enables novel-class predictions without retraining the head.
• src/models/heads_v3.py
• src/models/banks.py
• src/nmfc/affinity.py
Dual evaluation and outputs
run_openset performs two post-training evaluations: (A) rebuild a bank from all 100 plain training classes and report all/seen/novel top-1; (B) retain a seen-only bank and use minimum positive energy for OOD AUC between seen and novel test samples. Softmax uses its 100 logits for top-1 and MSP-derived OOD scoring. Shared metrics live in src/evaluate.py; persisted results are under 산출물/*/metrics.json and 산출물/*/history.json.
• src/train.py
• src/evaluate.py
• 산출물/c100v_shrb_open/metrics.json
Main entry points: train.py Training entry point · heads_v3.py Variant NMFC head · encoders.py ResNet50 encoder · variants.py Variant assembly
Components 16
Experiment Orchestration
- Open-set config · Defines the shrb NMFC and 100-logit softmax comparisons.
configs/cifar100_openset.yaml - Training entry point · Dispatches configured training and open-set evaluation runs.
src/train.py - Experiment lifecycle · Manages run outputs and completion caching.
src/utils/experiments.py
Open-Set Data
- CIFAR-100 image dataset · Keeps original 100-class labels while training data is restricted to seen examples.
src/datasets/image.py - Deterministic seen split · Selects the fixed 80 seen class IDs without relabeling.
src/datasets/samplers.py
Model and NMFC
- ResNet50 encoder · ImageNet-pretrained encoder producing embeddings.
src/models/encoders.py - Variant assembly · Interprets four-axis variants and selects NMFC or softmax heads.
src/variants.py - Variant NMFC head · Exposes minibatch-bank NMFC training and bank-based prediction.
src/models/heads_v3.py - APT phase controller · Transitions from linear-MFA warmup to NMFC optimization.
src/nmfc/apt.py - NMFC losses · Optimizes distance, affinity, and local-energy objectives.
src/nmfc/losses.py - Softmin energy · Processes neighbors for the shrb energy formulation.
src/nmfc/softmin.py
Inference and Evaluation
- Class-labeled reference bank · Stores prototypes and bank_classes for 80- or 100-class prediction.
src/models/banks.py - Bank affinity scoring · Scores embeddings against the reference bank.
src/nmfc/affinity.py - Dual open-set evaluation · Runs 100-bank classification and seen-bank OOD detection.
src/train.py - Shared metrics · Computes top-1, OOD AUC, and softmax MSP scoring.
src/evaluate.py - Persisted run results · Stores metrics and training history for completed runs.
산출물/c100v_shrb_open/metrics.json
Connections 20
- Open-set config → Training entry point: configures
- Training entry point → Experiment lifecycle: manages runs
- Training entry point → CIFAR-100 image dataset: loads data
- Deterministic seen split → CIFAR-100 image dataset: restricts training to 80 classes
- Training entry point → Variant assembly: builds configured model
- Variant assembly → ResNet50 encoder: uses embeddings
- Variant assembly → Variant NMFC head: selects shrb head
- ResNet50 encoder → Variant NMFC head: embedding batches
- APT phase controller → Variant NMFC head: controls training phase
- NMFC losses → Variant NMFC head: optimizes head
- Softmin energy → NMFC losses: local energy
- Variant NMFC head → Class-labeled reference bank: fits labeled coresets
- Class-labeled reference bank → Bank affinity scoring: prototypes and classes
- ResNet50 encoder → Bank affinity scoring: test embeddings
- Training entry point → Dual open-set evaluation: after training
- Dual open-set evaluation → Class-labeled reference bank: rebuilds 100-class bank
- Bank affinity scoring → Dual open-set evaluation: bank predictions and energy
- Dual open-set evaluation → Shared metrics: classification and OOD scores
- Shared metrics → Persisted run results: writes metrics
- Experiment lifecycle → Persisted run results: persists history