Skip to content

tmlr-group/NAMMD

 
 

Repository files navigation

Norm-Adaptive Maximum Mean Discrepancy

Reproducibility code for Norm-Adaptive Maximum Mean Discrepancy, presented at ICML 2026. This work is done by

The code is organized around the important experiments in the paper.

Setup

Install the dependencies from environment.yml.

Most scripts write text results under Results/... relative to the repository root. Before running experiments, create the result folders used by the scripts:

mkdir -p Results/tst_sample_size/test_power Results/tst_sample_size/typeI_error
mkdir -p Results/power_tv/test_power Results/power_tv/typeI_error
mkdir -p Results/power_epsn
mkdir -p Results/demos

Many experiments are GPU-oriented and use torch.device("cuda") by default. For quick CPU checks, override the device in the relevant script or argument.

Demo

Run the reference-sample kernel-selection demo:

python demos/mixture_gaussian_dct.py

The demo uses Gaussian mixtures where the alternative pair has a modestly larger signed mixture contrast than the reference pair. MMD therefore has real power, while NAMMD is stronger because its normalization captures the change in the RKHS norm structure. The MMD and NAMMD Gaussian bandwidths are selected from independent pilot samples. Because this is a synthetic demo, the tolerance level epsilon is the population value of the reference pair. For each test sample, the rejection threshold is computed from that test sample's asymptotic variance, as in the DCT procedure. CSV summaries are written to Results/demos/.

Main Paper Experiments

Figure 1: MMD, NAMMD, and RKHS Norms

Script:

python "Figure 1.py"

Outputs are written to pictures/, including pictures/Figure1_continuous_gmm.pdf and the corresponding CSV summary.

Figure 2: TST Benchmark Against Existing Methods

Directory:

TST_exp/tst_sample_size/

Main NAMMD method:

cd TST_exp/tst_sample_size
python NAMMDFuse.py

Baselines used for the same figure:

python MMDFuse.py
python MMDAgg.py
python MEmabid.py
python MMD_D.py
python ACTT.py
python AutoTST.py
python AutoTST_deep.py

These scripts save raw rejection-rate summaries to Results/tst_sample_size/.... Figure plotting is not centralized in this repo; the text outputs are the experiment artifacts used to build the figure.

Table 1: DCT With Total-Variation Reference Construction

Directory:

DCT_exp/power_tv/

Run the dataset scripts:

cd DCT_exp/power_tv
python blob.py
python higgs.py
python hdgm.py
python mnist.py
python cifar.py

The default --check 1 setting reports power. Scripts with --check 0 report the corresponding type-I error for the same construction.

Table 2: DCT With NAMMD Reference Levels

Directory:

DCT_exp/power_epsn/

Run the dataset scripts:

cd DCT_exp/power_epsn
python blob.py
python higgs.py
python hdgm.py
python mnist.py
python cifar.py

This is the main continuous/high-dimensional DCT comparison between MMD-based DCT and NAMMD-based DCT. The Gaussian bandwidths for MMD and NAMMD are selected separately from reference samples.

Figure 3: ImageNet Variant Closeness

Directory:

DA_exp/

Feature generation:

cd DA_exp
python dataprocess.py

Main DCT experiment:

python main2.py

This corresponds to the ImageNet / ImageNet-V2 / ImageNet-R / ImageNet-Sketch / ImageNet-A closeness comparison. The script expects the precomputed feature files generated by dataprocess.py.

Figure 4: Confidence-Gap Case Study

Directory:

DA_exp/

Script:

cd DA_exp
python main.py

This is the ImageNet confidence-gap case study based on selected class groups.

Figure 5: Adversarial Perturbation Case Study

Directory:

ADV_exp/

Typical workflow:

cd ADV_exp
python train_model.py
python adv_generator.py
python main.py

main.py assumes the adversarial feature artifacts have already been generated.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%