Code Monkey home page Code Monkey logo

dfmx-augmentation's Introduction


Introduction

Neural networks are prone to learn easy solutions from superficial statistics in the data, namely shortcut learning, which impairs generalization and robustness of models. We propose a data augmentation strategy, named DFM-X, that leverages knowledge about frequency shortcuts, encoded in Dominant Frequencies Maps computed for image classification models. We randomly select X% training images of certain classes for augmentation, and process them by retaining the frequencies included in the DFMs of other classes. This strategy compels the models to leverage a broader range of frequencies for classification, rather than relying on specific frequency sets. Thus, the models learn more deep and task-related semantics compared to their counterpart trained with standard setups. Unlike other commonly used augmentation techniques which focus on increasing the visual variations of training data, our method targets exploiting the original data efficiently, by distilling prior knowledge about destructive learning behavior of models from data. Our experimental results demonstrate that DFM-X improves robustness against common corruptions and adversarial attacks. It can be seamlessly integrated with other augmentation techniques to further enhance the robustness of models.

Quick start

  • Clone this repository:
git clone https://github.com/nis-research/dfmX-augmentation.git
cd dfmX-augmentation
  • Installation
    • Python 3.9.12, cuda-11.7, cuda-11.x_cudnn-8.6
      • You can create a virtual environment with conda and activate the environment before the next step
         conda create -n virtualenv  python=3.9 anaconda
         source activate virtualenv
         conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
        
    • Install other packages
       pip install -r requirements.txt
      
      
  • Computing DFMs of CIFAR for a pre-trained model, e.g.
python -u Compute_DFM_CIFAR.py  --backbone_model resnet18 --model_path checkpoints/last.ckpt      
  • Evalating perfomance of models when tested with only dominant frequencies, e.g.
python -u Evaluation/verify_mask.py  --backbone_model resnet18  --model_path checkpoints/last.ckpt  --m_path  ./DFMs/resnet18
  • Training models with DFM-X, e.g.
python -u train.py   --backbone_model resnet18 --lr 0.01  --save_dir results/   --p 0.3  --masks  ./DFMs/resnet18.pkl

Citation

@inproceedings{wang2023dfmx,
title={{DFM-X}: Augmentation by Leveraging Prior Knowledge of Shortcut Learning},
author={Shunxin Wang and Christoph Brune and Raymond Veldhuis and Nicola Strisciuglio},
booktitle={International Conference on Computer Vision Workshops (ICCVW)},
year={2023}
}

dfmx-augmentation's People

Contributors

nicstrisc avatar nis-research avatar shunxinwang avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.