Skip to content

97yong/domain-adaptation-signal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌐 Domain-Adversarial Neural Network (DANN) for Domain Adaptation - 1D Signal

This project implements a DANN (Domain-Adversarial Neural Network) to perform robust fault classification under domain shift using the bearing dataset.


πŸ“ Project Structure

dann_pipeline/
β”œβ”€β”€ main.py              # Entry point (load, train, evaluate)
β”œβ”€β”€ config.py            # Argument parser
β”œβ”€β”€ dataset.py           # Source/target dataloaders
β”œβ”€β”€ model.py             # DANN architecture (feature extractor + classifiers)
β”œβ”€β”€ train.py             # Adversarial training routine
β”œβ”€β”€ test.py              # Final evaluation on target domain
β”œβ”€β”€ utils.py             # Optional tools (e.g. plotting)
β”œβ”€β”€ data/                # .npy input files
└── result/              # model.pt, logs, loss curves

πŸ“₯ Dataset

This project uses two publicly available bearing fault datasets adapted for domain adaptation experiments:

For signal preprocessing and conversion into .npy format, refer to the preprocessing code in this repository:
πŸ”§ https://github.com/97yong/signal-fault-classification

Preprocessed data is saved in the following format as .npy:

data/
β”œβ”€β”€ X_source.npy
β”œβ”€β”€ Y_source.npy
β”œβ”€β”€ X_target.npy
β”œβ”€β”€ Y_target.npy
β”œβ”€β”€ X_target_test.npy
└── Y_target_test.npy

βš™οΈ Training Options

You can configure training parameters via config.py or pass them through opt.

ArgumentDescriptionDefault
--epochsNumber of training epochs10
--lrLearning rate1e-4
--batch_sizeMini-batch size64

🧠 Model Overview

DANN consists of:

  • Feature Extractor – 1D CNN layers
  • Label Classifier – Predicts class labels for source domain
  • Domain Classifier – Predicts domain (source/target) using GRL (gradient reversal)

Training is done with adversarial loss to align the feature distributions.


πŸš€ How to Run

pip install numpy torch scikit-learn tqdm matplotlib
python main.py

This will:

  1. Load source/target domain data
  2. Train a domain-adversarial model
  3. Evaluate performance on target test data

Views

πŸ“š Reference

Ganin, Y., & Lempitsky, V. (2015).
"Unsupervised Domain Adaptation by Backpropagation."
In Proceedings of the 32nd International Conference on Machine Learning (ICML), 1180–1189.
πŸ”— arXiv:1409.7495


About

πŸ”„ [Signal] Domain adaptation for fault classification using DANN (Source β†’ Target)

Topics

Resources

Stars

Watchers

Forks

Languages