Giter Site home page Giter Site logo

lmser-pytorch's Introduction

LMSER-pytorch

Introduction

A pytorch implementation of LMSER, which is a bidirectional architecture with some built-in natures. In this project, we implement the Dual Connection Weight (DCW) property of LMSER. We implemented both LMSER with and without the pseudo inverse constrain, and compare their performance on reconstructing MNIST and Fashion-MNIST with AutoEncoder. We also add the supervised learning to the middle-layer embedding vector (16-d vector in our implementation), which aims to test the supervised learning effect on original reconstruction task.

Prerequisites

  • Linux, Ubuntu 16.04 or 18.04
  • Python 3.6+
  • Pytorch 1.4.0+
  • CUDA 10.0+

Installation

  1. Create a conda virtual environment and activate it.
conda create -n lmser python=3.6
conda activate lmser
  1. Install Pytorch and torchvision following the official instruction.

  2. Clone the LMSER-Pytorch repository.

git clone https://github.com/Simon-Fuhaoyuan/LMSER-pytorch
  1. Install build requirements
cd LMSER-pytorch
pip install -r requirements.txt

Usage

We offer both training and testing codes.

To train a model, please run

python train.py [-h] [--epochs EPOCHS] [--batch_size BATCH_SIZE] [--lr LR] \
                [--mean MEAN] [--std STD] [--dataset DATASET] \
                [--weight_dir WEIGHT_DIR] [--image_dir IMAGE_DIR] [--cpu_only] \
                [--no_test] \
                model

For example, to train AutoEncoder, run

python train.py AutoEncoder --epochs 50 --batch_size 64 --dataset mnist

To test a model, run

python test.py [-h] [--dataset DATASET] [--batch_size BATCH_SIZE] \
               [--mean MEAN] [--std STD] [--image_dir IMAGE_DIR] [--cpu_only] \
               model weight

For example, to test a trained model, whose weight model is saved at ./weight_dir/AutoEncoder.pth, run

python test.py AutoEncoder ./weight_dir/AutoEncoder.pth --dataset mnist

The usage of train_supervise.py and test_supervise.py is quite similar, but they will load the supervised version of model and train or test.

For more usages, please refer to experiments_command.txt.

lmser-pytorch's People

Contributors

simon-fuhaoyuan avatar

Watchers

James Cloos 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.