Skip to content

xmed-lab/CUDA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CUDA: Concept-Based Unsupervised Domain Adaptation

License: MIT

Official implementation of "Concept-Based Unsupervised Domain Adaptation" (ICML 2025).

Overview

CUDA (Concept-Based Unsupervised Domain Adaptation) is a novel approach for unsupervised domain adaptation that leverages concept-based learning to improve domain transfer performance. The method combines domain adversarial training with concept-aware feature learning to achieve better alignment between source and target domains.

Project Structure

CUDA/
├── main.py                    # Main training and evaluation script
├── utils.py                   # Utility functions and data loading
├── models/
│   └── domain_adversarial_network.py  # Domain discriminator implementation
├── alignemnt/
│   └── dann.py               # Domain adversarial loss and classifier
├── data/                     # Dataset implementations
│   ├── MNIST/
│   ├── Skincon/
│   └── Waterbirds/
├── analysis/                 # Analysis and visualization tools
│   ├── __init__.py          # Feature collection utilities
│   ├── a_distance.py        # A-distance calculation
│   ├── pca.py              # PCA analysis
│   └── tsne.py             # t-SNE visualization
└── README.md

Installation

# Install PyTorch with CUDA support
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

# Install other dependencies
pip install timm==0.6.13
pip install numpy==1.26.4
pip install matplotlib==3.5.2
pip install --extra-index-url https://pypi.org/simple/ -i https://test.pypi.org/simple/ tllib==0.4
pip install scikit-learn
pip install wandb  # for experiment tracking

Usage

Basic Training

python main.py --data waterbirds \
               --root ./data/Waterbirds/waterbirds-dann-2 \
               --epochs 50 \
               --batch-size 32 \
               --lr 1e-3 \
               --lambda_c 5.0 \
               --lambda_t 0.3 \
               --tau 0.7

Key Parameters

  • --data: Dataset choice (waterbirds, mnist, skincon)
  • --lambda_c: Trade-off parameter for concept loss
  • --lambda_t: Trade-off parameter for transfer loss
  • --tau: Relax threshold parameter for transfer loss
  • --bottleneck_dim: Bottleneck dimension
  • --concept_emb_dim: Concept embedding dimension

Evaluation and Analysis

# Test mode
python main.py --phase test --root ./data --data waterbirds

# Analysis mode with visualizations
python main.py --phase analysis --root ./data --data waterbirds

# Concept analysis
python main.py --phase concept-analysis --root ./data --data waterbirds

Supported Datasets

  1. Waterbirds, CUB: Bird classification with spurious background correlations
  2. MNIST, MNIST-M, SVHN, USPS: Handwritten digit recognition with domain shifts
  3. Skincon: Skin condition classification across different skin tones

Citation

If you use this code in your research, please cite:

@article{CUDA,
  title={Concept-Based Unsupervised Domain Adaptation},
  author={Xu, Xinyue and Hu, Yueying and Tang, Hui and Qin, Yi and Mi, Lu and Wang, Hao and Li, Xiaomeng},
  journal={arXiv preprint arXiv:2505.05195},
  year={2025}
}

Acknowledgments

About

ICML 2025: Concept-Based Unsupervised Domain Adaptation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages