How junghwamin/nmfc-plan6-novel-transfer works
Purpose and entry points
This is a PyTorch research pipeline for reassessing NMFC’s shrb open-set classifier on CIFAR-100. It tests whether poor novel-class transfer comes from fine-tuning specialization and whether reference-bank performance belongs to NMFC training or bank-based inference.
Primary entry points:
• Training/open-set experiments: src/train.py
• Bank-only reevaluation of cached encoders: scripts/eval_softmax_bank.py
• Experiment specifications: configs/cifar100_openset_nseen.yaml, configs/cifar100_openset_freeze.yaml, configs/cifar100_openset_freeze_smoke.yaml
Data and open-set partitioning
CIFAR-100 is loaded and partitioned into seen versus novel classes while preserving the full test-label space. n_seen controls the amount of supervised training data/classes and is swept at 50/80/90.
• src/datasets/image.py
• src/datasets/samplers.py
• configs/cifar100_openset_nseen.yaml
Training orchestration and experiment boundary
run_openset and its image-training core coordinate encoder construction, variant resolution, optimization, phase scheduling, bank fitting, cache/run management, and final metrics. The freeze_backbone gate makes the pretrained ResNet body non-trainable while retaining its projection layer and head parameters for linear-probe-like training.
• src/train.py
• src/utils/experiments.py
• configs/cifar100_openset_freeze.yaml
Encoder and representation boundary
ResNet50Encoder starts from ImageNet-pretrained ResNet-50 and replaces its classifier with a 128-dimensional projection. It emits raw, non-L2-normalized embeddings, preserving Euclidean distance behavior used by NMFC energy and bank computations.
• src/models/encoders.py
• src/models/baselines.py
Variant assembly and NMFC head
Variant resolution converts four configured axes—energy, logit, APT schedule, and bank mode—into the selected head. The main shrb path uses VariantNMFCHead, with soft-min energies, hinge-temperature logits, reciprocal APT, and minibatch behavior. The head owns coreset-bank fitting, bank energy calculation, prediction, and OOD scoring.
• src/variants.py
• src/models/heads_v3.py
• src/models/banks.py
NMFC mathematical/training stages
The reusable NMFC layer implements local soft-min/kNN energy, affinity computation, energy formulations, loss construction, and a two-phase reciprocal APT controller. Training applies NMFC loss to encoder/head outputs; after training, a classwise coreset reference bank is fit for open-set and expanded-class evaluation.
• src/nmfc/softmin.py
• src/nmfc/affinity.py
• src/nmfc/losses.py
• src/nmfc/apt.py
Evaluation and bank-only control experiment
Standard evaluation reports open top-1 for all/seen/novel classes, OOD AUC, and embedding silhouette. The independent bank script bypasses training: it loads a cached softmax or shrb encoder, embeds all 100 classes, fits the same NMFC coreset bank, then predicts by minimum positive bank energy. This isolates bank inference from encoder-training methodology.
• src/evaluate.py
• scripts/eval_softmax_bank.py
• src/models/heads_v3.py
Runtime, artifacts, and external dependencies
The system is Python/PyTorch-based and depends on CIFAR-100 plus torchvision/ImageNet pretrained ResNet-50 weights. Training/checkpoints and excluded embedding caches are external runtime artifacts; committed result summaries live under 산출물/, including metrics.json and training history.json. No dedicated test suite exists.
• 산출물/c100v_shrb_open_frz/metrics.json
• 산출물/c100v_softmax_open_bank/metrics.json
• 산출물/_checkpoints_원본경로.txt
Main entry points: train.py Open-set training entry · encoders.py ResNet50 encoder · heads_v3.py Variant NMFC head (shrb) · cifar100_openset_nseen.yaml Open-set experiment specs
Components 17
Data & splits
- CIFAR-100 + pretrained weights · CIFAR-100 retains its full 100-class test label space; ResNet-50 begins from ImageNet weights.
- Image dataset partition · Partitions labels into seen and novel classes.
src/datasets/image.py - Seen-class samplers · Controls supervised data exposure for n_seen.
src/datasets/samplers.py
Training
- Open-set experiment specs · Defines n_seen sweeps, variants, and frozen-backbone runs.
configs/cifar100_openset_nseen.yaml - Open-set training entry · Runs encoder/head construction, optimization, phases, bank fitting, caching, and final metrics.
src/train.py - Run management · Manages experiment runs and caches.
src/utils/experiments.py - ResNet50 encoder · Pretrained ResNet-50 with a 128-D raw embedding projection.
src/models/encoders.py - Frozen-backbone mode · Freezes the ResNet body while training projection and head parameters.
configs/cifar100_openset_freeze.yaml
NMFC variant & bank
- Variant resolver · Selects the head from energy, logit, APT, and bank-mode axes.
src/variants.py - Variant NMFC head (shrb) · Owns bank fitting, bank energy, prediction, and OOD scoring.
src/models/heads_v3.py - Soft-min & affinity energy · Computes local soft-min/kNN energy and affinities.
src/nmfc/softmin.py - NMFC loss · Builds the training objective from NMFC energies.
src/nmfc/losses.py - Reciprocal APT controller · Applies the two-phase reciprocal APT schedule.
src/nmfc/apt.py - Classwise coreset bank · Fits per-class references for open-set and expanded-class inference.
src/models/banks.py
Evaluation
- Standard evaluation · Reports all/seen/novel top-1, OOD AUC, and embedding silhouette.
src/evaluate.py - Bank-only reevaluation · Loads cached encoders, refits the bank over all classes, and predicts by minimum positive bank energy.
scripts/eval_softmax_bank.py - Committed result summaries · Stores metrics and training histories; checkpoints and embedding caches are runtime artifacts.
산출물/c100v_shrb_open_frz/metrics.json
Connections 22
- CIFAR-100 + pretrained weights → Image dataset partition: loaded by
- Open-set experiment specs → Image dataset partition: sets n_seen
- Image dataset partition → Seen-class samplers: partitioned data
- Open-set experiment specs → Open-set training entry: configures
- Seen-class samplers → Open-set training entry: training batches
- Run management → Open-set training entry: run/cache support
- Frozen-backbone mode → Open-set training entry: freeze_backbone gate
- CIFAR-100 + pretrained weights → ResNet50 encoder: ImageNet initialization
- Open-set training entry → ResNet50 encoder: optimizes
- Open-set experiment specs → Variant resolver: variant axes
- Variant resolver → Variant NMFC head (shrb): selects shrb head
- ResNet50 encoder → Variant NMFC head (shrb): raw 128-D embeddings
- Soft-min & affinity energy → NMFC loss: energy terms
- Reciprocal APT controller → NMFC loss: phase schedule
- NMFC loss → Open-set training entry: training objective
- Open-set training entry → Classwise coreset bank: fits after training
- Classwise coreset bank → Variant NMFC head (shrb): reference energies
- Variant NMFC head (shrb) → Standard evaluation: predictions and OOD scores
- Standard evaluation → Committed result summaries: writes metrics
- ResNet50 encoder → Bank-only reevaluation: cached encoder embeddings
- Bank-only reevaluation → Classwise coreset bank: refits same bank
- Bank-only reevaluation → Committed result summaries: control metrics