Code Monkey home page Code Monkey logo

can-supcon-ids's Introduction

CAN-SupCon-IDS

This is the implementation of the paper "SupCon ResNet and Transfer Learning for the In-vehicle Intrusion Detection System"

Environment

  • tensorflow: 2.0
  • torch: 1.9

How to run

Train test split

python3 train_test_split.py --data_path ../Data/ --car_model None --window_size 29 --strided 15 --rid 2

Baseline train

python3 train_baseline.py --data_dir ../Data/TFrecord_w29_s15/ \\
                          --model resnet18 --save_freq 10 --window_size 29 \\
                          --num_workers 8 --cosine --epochs 50 \\
                          --batch_size 256 --learning_rate 0.0005 --rid 5

Supcon train

python3 train_supcon.py --data_dir ../Data/TFrecord_w29_s15/ \\
                      --model resnet18 --save_freq 10 --window_size 29 \\
                      --epochs 200 --num_workers 8 --temp 0.07 \\
                      --learning_rate 0.1 --learning_rate_classifier 0.01 \\
                      --cosine --epoch_start_classifier 170 --rid 3 --batch_size 512

Transfer

Random initialization

python3 transfer.py --data_path ../Data/Survival/ --car_model Spark \\
                    --pretrained_model resnet --tf_algo tune \\
                    --num_classes 4 --window_size 29 --strided 10 \\
                    --lr_tune 0.001 --tune_epochs 20

Using CE ResNet as the pretrained model

python3 transfer.py --data_path ../Data/Survival/ --car_model Spark \\
                    --window_size 29 --strided 10 --num_classes 4 --lr_transfer 0.01 \\
                    --lr_tune 0.001 --transfer_epochs 50 --tune_epochs 10 \\
                    --tf_algo transfer_tune --pretrained_model resnet \\
                    --pretrained_path save/smallresnet18.ce1_gamma0_lr0.001_bs256_50epochs_051822_100142_cosine/models/ \\
                    --source_ckpt 50

Using SupCon ResNet as the pretrained model

python3 transfer.py --data_path ../Data/Survival/ --car_model Spark \\
                    --window_size 29 --strided 10 --num_classes 4 --lr_transfer 0.01 \\
                    --lr_tune 0.001 --transfer_epochs 40 --tune_epochs 20 \\
                    --tf_algo transfer_tune --pretrained_model supcon \\
                    --pretrained_path save/SupCon_resnet18.ce2_lr0.05_0.01_bs512_200epoch_temp0.07_052322_102305_cosine_warm/models/ \\
                    --source_ckpt 200

Acknowledgement

This codebase was adapted from SupContrast.

can-supcon-ids's People

Contributors

htn274 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.