GithubHelp home page GithubHelp logo

b1uec1oud / sesemi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vuptran/sesemi

0.0 0.0 0.0 2.58 MB

semi-supervised image classification with self-supervision (Keras+TensorFlow)

License: MIT License

Python 100.00%

sesemi's Introduction

Semi-Supervised Learning with Self-Supervision

This repository contains a Keras implementation of the SESEMI architecture for semi-supervised image classification, as described in the arXiv paper:

Tran, Phi Vu (2019) Semi-Supervised Learning with Self-Supervised Networks.

Approach

schematic

The training and evaluation of the SESEMI architecture for semi-supervised learning is summarized as follows:

  1. Separate the input data into labeled and unlabeled branches. The unlabeled branch consists of all available training examples, but without ground truth label information;
  2. Perform geometric transformations on unlabeled data to produce six proxy labels defined as image rotations belonging in the set of {0,90,180,270} degrees along with horizontal (left-right) and vertical (up-down) flips;
  3. Apply input data augmentation and noise to each branch independently;
  4. At each training step, sample two mini-batches having the same number of unlabeled and labeled examples as inputs to a shared CNN trunk. Note that labeled examples will repeat in a mini-batch because the number of unlabeled examples is much greater;
  5. Compute the supervised cross-entropy loss using ground truth labels and the self-supervised cross-entropy loss using proxy labels generated from image rotations and flips;
  6. Update CNN parameters via stochastic gradient descent by minimizing the sum of supervised and self-supervised loss components;
  7. At inference time, take the supervised branch of the network to make predictions on test data and discard the self-supervised branch.

Requirements

The code is tested on Ubuntu 16.04 with the following components:

Software

  • Anaconda Python 3.6;
  • Keras 2.2.4 with TensorFlow GPU 1.12.0 backend;
  • CUDA 9.1 with CuDNN 7.1 acceleration.

Hardware

This reference implementation loads all data into system memory and utilizes GPU for model training and evaluation. The following hardware specifications are highly recommended:

  • At least 64GB of system RAM;
  • NVIDIA GeForce GTX TITAN X GPU or better.

Usage

For training and evaluation, execute the following bash commands in the same directory where the code resides. Ensure the datasets have been downloaded into their respective directories.

# Set the PYTHONPATH environment variable.
$ export PYTHONPATH="/path/to/this/repo:$PYTHONPATH"

# Train and evaluate SESEMI.
$ python train_evaluate_sesemi.py --network <net_str> --dataset <dataset_str> --labels <nb_labels> --gpu <gpu_id>

# Train and evaluate SESEMI with unlabeled extra data from Tiny Images.
$ python train_evaluate_sesemi_tinyimages.py --network <net_str> --extra <nb_extra> --gpu <gpu_id>

The required flags are:

  • <net_str> refers to either convnet or wrn architecture;
  • <dataset_str> refers to one of three supported datasets svhn, cifar10, and cifar100;
  • <nb_labels> is an integer denoting the number of labeled examples;
  • <nb_extra> denotes the amount of unlabeled extra data to sample from Tiny Images;
  • <gpu_id> is a string denoting the GPU device ID, defaults to 0 if not specified.

sesemi's People

Contributors

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