Disturbing Target Values for Neural Network regularization: attacking the loss layer to prevent overfitting

Overview

Disturbing Target Values for Neural Network regularization: attacking the loss layer to prevent overfitting

1. Classification Task

PyTorch implementation of DisturbLabel: Regularizing CNN on the Loss Layer [CVPR 2016] extended with Directional DisturbLabel method.

This classification code is built on top of https://github.com/amirhfarzaneh/disturblabel-pytorch/blob/master/README.md project and utilizes implementation from ResNet 18 from https://github.com/huyvnphan/PyTorch_CIFAR10

Directional DisturbLabel

  if args.mode == 'ddl' or args.mode == 'ddldr':
      out = F.softmax(output, dim=1)
      norm = torch.norm(out, dim=1)
      out = out / norm[:, None]
      idx = []
      for i in range(len(out)):
          if out[i,target[i]] > .5:
              idx.append(i)
              
      if len(idx) > 0:
          target[idx] = disturb(target[idx]).to(device) 

Usage

python main_ddl.py --mode=dl --alpha=20

Most important arguments

--dataset - which data to use

Possible values:

value dataset
MNIST MNIST
FMNIST Fashion MNIST
CIFAR10 CIFAR-10
CIFAR100 CIFAR-100
ART Art Images: Drawing/Painting/Sculptures/Engravings
INTEL Intel Image Classification

Default: MNIST

-- mode - regularization method applied

Possible values:

value method
noreg Without any regularization
dl Vanilla DistrubLabel
ddl Directional DisturbLabel
dropout Dropout
dldr DistrubLabel+Dropout
ddldl Directional DL+Dropout

Default: ddl

--alpha - alpha for vanilla Distrub label and Directional DisturbLabel

Possible values: int from 0 to 100. Default: 20

--epochs - number of training epochs

Default: 100

2. Regression Task

DisturbValue

def noise_generator(x, alpha):
    noise = torch.normal(0, 1e-8, size=(len(x), 1))
    noise[torch.randint(0, len(x), (int(len(x)*(1-alpha)),))] = 0

    return noise

DisturbError

def disturberror(outputs, values):
    epsilon = 1e-8
    e = values - outputs
    for i in range(len(e)):
        if (e[i] < epsilon) & (e[i] >= 0):
            values[i] = values[i] + e[i] / 4
        elif (e[i] > -epsilon) & (e[i] < 0):
            values[i] = values[i] - e[i] / 4

    return values

Datasets

  1. Boston: 506 instances, 13 features
  2. Bike Sharing: 731 instances, 13 features
  3. Air Quality(AQ): 9357 instances, 10 features
  4. make_regression(MR): 5000 instances, 30 features (random sample for regression)
  5. Housing Price - Kaggle(HP): 1460 instances, 81 features
  6. Student Performance (SP): 649 instances, 13 features (20 - categorical were dropped)
  7. Superconductivity Dataset (SD): 21263 instances, 81 features
  8. Communities & Crime (CC): 1994 instances, 100 features
  9. Energy Prediction (EP): 19735 instancies, 27 features

Experiment Setting

Model: MLP which has 3 hidden layers

Result: Averaged over 20 runs

Hyperparameters: Using grid search options

Usage

python main_new.py --de y --dataset "bike" --dv_annealing y --epoch 100 --T 80
python main_new.py --de y --dv y --dataset "bike" -epoch 100
python main_new.py --de y --l2 y --dataset "air" -epoch 100
python main_new.py --dv y --dv_annealing y --dataset "air" -epoch 100 #for annealing setting dv should be "y"

--dataset: 'bike', 'air', 'boston', 'housing', 'make_sklearn', 'superconduct', 'energy', 'crime', 'students'
--dropout, --dv(disturbvalue), --de(disturberror), --l2, --dv_annealing: (string) y / n
--lr: (float)
--batch_size, --epoch, --T(cos annealing T): (int)
-- default dv_annealing: alpha_min = 0.05, alpha_max = 0.12, T_i = 80
You might also like...
Losslandscapetaxonomy - Taxonomizing local versus global structure in neural network loss landscapes
Losslandscapetaxonomy - Taxonomizing local versus global structure in neural network loss landscapes

Taxonomizing local versus global structure in neural network loss landscapes Int

[CVPR 2022] Official code for the paper:
[CVPR 2022] Official code for the paper: "A Stitch in Time Saves Nine: A Train-Time Regularizing Loss for Improved Neural Network Calibration"

MDCA Calibration This is the official PyTorch implementation for the paper: "A Stitch in Time Saves Nine: A Train-Time Regularizing Loss for Improved

The code for SAG-DTA: Prediction of Drug–Target Affinity Using Self-Attention Graph Network.

SAG-DTA The code is the implementation for the paper 'SAG-DTA: Prediction of Drug–Target Affinity Using Self-Attention Graph Network'. Requirements py

Consistency Regularization for Adversarial Robustness
Consistency Regularization for Adversarial Robustness

Consistency Regularization for Adversarial Robustness Official PyTorch implementation of Consistency Regularization for Adversarial Robustness by Jiho

Code for CoMatch: Semi-supervised Learning with Contrastive Graph Regularization

CoMatch: Semi-supervised Learning with Contrastive Graph Regularization (Salesforce Research) This is a PyTorch implementation of the CoMatch paper [B

The code release of paper 'Domain Generalization for Medical Imaging Classification with Linear-Dependency Regularization' NIPS 2020.
The code release of paper 'Domain Generalization for Medical Imaging Classification with Linear-Dependency Regularization' NIPS 2020.

Domain Generalization for Medical Imaging Classification with Linear Dependency Regularization The code release of paper 'Domain Generalization for Me

PyTorch implementation of Self-supervised Contrastive Regularization for DG (SelfReg)
PyTorch implementation of Self-supervised Contrastive Regularization for DG (SelfReg)

SelfReg PyTorch official implementation of Self-supervised Contrastive Regularization for Domain Generalization (SelfReg, https://arxiv.org/abs/2104.0

Code for ACL2021 paper Consistency Regularization for Cross-Lingual Fine-Tuning.

xTune Code for ACL2021 paper Consistency Regularization for Cross-Lingual Fine-Tuning. Environment DockerFile: dancingsoul/pytorch:xTune Install the f

IJCAI2020 & IJCV 2020 :city_sunrise: Unsupervised Scene Adaptation with Memory Regularization in vivo
IJCAI2020 & IJCV 2020 :city_sunrise: Unsupervised Scene Adaptation with Memory Regularization in vivo

Seg_Uncertainty In this repo, we provide the code for the two papers, i.e., MRNet:Unsupervised Scene Adaptation with Memory Regularization in vivo, IJ

Owner
Yongho Kim
Research Assistant
Yongho Kim
Sparse Progressive Distillation: Resolving Overfitting under Pretrain-and-Finetune Paradigm

Sparse Progressive Distillation: Resolving Overfitting under Pretrain-and-Finetu

null 3 Dec 5, 2022
Code for ICCV 2021 paper: ARAPReg: An As-Rigid-As Possible Regularization Loss for Learning Deformable Shape Generators..

ARAPReg Code for ICCV 2021 paper: ARAPReg: An As-Rigid-As Possible Regularization Loss for Learning Deformable Shape Generators.. Installation The cod

Bo Sun 132 Nov 28, 2022
RDA: Robust Domain Adaptation via Fourier Adversarial Attacking

RDA: Robust Domain Adaptation via Fourier Adversarial Attacking Updates 08/2021: check out our domain adaptation for video segmentation paper Domain A

null 17 Nov 30, 2022
Universal Adversarial Triggers for Attacking and Analyzing NLP (EMNLP 2019)

Universal Adversarial Triggers for Attacking and Analyzing NLP This is the official code for the EMNLP 2019 paper, Universal Adversarial Triggers for

Eric Wallace 248 Dec 17, 2022
Implement of "Training deep neural networks via direct loss minimization" in PyTorch for 0-1 loss

This is the implementation of "Training deep neural networks via direct loss minimization" published at ICML 2016 in PyTorch. The implementation targe

Cuong Nguyen 1 Jan 18, 2022
Recall Loss for Semantic Segmentation (This repo implements the paper: Recall Loss for Semantic Segmentation)

Recall Loss for Semantic Segmentation (This repo implements the paper: Recall Loss for Semantic Segmentation) Download Synthia dataset The model uses

null 32 Sep 21, 2022
An implementation for the loss function proposed in Decoupled Contrastive Loss paper.

Decoupled-Contrastive-Learning This repository is an implementation for the loss function proposed in Decoupled Contrastive Loss paper. Requirements P

Ramin Nakhli 71 Dec 4, 2022
Prevent `CUDA error: out of memory` in just 1 line of code.

?? Koila Koila solves CUDA error: out of memory error painlessly. Fix it with just one line of code, and forget it. ?? Features ?? Prevents CUDA error

RenChu Wang 1.7k Jan 2, 2023
This repository is an implementation of paper : Improving the Training of Graph Neural Networks with Consistency Regularization

CRGNN Paper : Improving the Training of Graph Neural Networks with Consistency Regularization Environments Implementing environment: GeForce RTX™ 3090

THUDM 1 Dec 9, 2021
PyTorch framework, for reproducing experiments from the paper Implicit Regularization in Hierarchical Tensor Factorization and Deep Convolutional Neural Networks

Implicit Regularization in Hierarchical Tensor Factorization and Deep Convolutional Neural Networks. Code, based on the PyTorch framework, for reprodu

Asaf 3 Dec 27, 2022