Code Monkey home page Code Monkey logo

msdnet-gcn's Introduction

MSDNet - reproducibility and applying GCN blocks with separable kernel

This repository contains a reproduction code (in PyTorch) for "MSDNet: Multi-Scale Dense Networks for Resource Efficient Image Classification"

Contents

  1. Introduction
  2. Usage

Introduction

MSDNet is a novel approach fo image classification with computational resource limits at test time. This repository provides an implementation based on the technical description provided in the paper. Currently this code implements the support for Cifar-10 and Cifar-100.

Moreover, this code integrates the support for GCN based layers instead of normal convolution layers, in order to reduce the model parameters.

Usage

Dependencies

Train

As an example, use the following command to train an MSDNet on Cifar10

python3 main.py --model msdnet -b 64 -j 2 cifar10 --msd-blocks 10 --msd-base 4 \
--msd-step 2 --msd-stepmode even --growth 6-12-24 --gpu 0

As an example, use the following command to train an MSDNet on Cifar100 with GCN block

python3 main.py --model msdnet -b 64 -j 2 cifar100 --msd-blocks 10 --msd-base 3 \
--msd-step 1 --msd-stepmode even --growth 6-12-24 --gpu 0  --msd-gcn --msd-gcn-kernel 5 \
--msd-share-weights --msd-all-gcn

Evaluation

We take the Cifar10 model trained above as an example.

To evaluate the trained model, use evaluate to evaluate from the default checkpoint directory:

python3 main.py --model msdnet -b 64 -j 2 cifar100 --msd-blocks 10 --msd-base 3 \
--msd-step 1 --msd-stepmode even --growth 6-12-24 --gpu 0 --msd-gcn --msd-gcn-kernel 5 \
--msd-share-weights --msd-all-gcn --resume --evaluate

Other Options

For detailed options, please python main.py --help

For more examples and using pre-trained models, please less script.sh

msdnet-gcn's People

Contributors

avirambh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

msdnet-gcn's Issues

It seems a bug

I downloaded the code and run it by the command: python3 main.py --model msdnet -b 64 -j 2 cifar10 --msd-blocks 10 --msd-base 4 --msd-step 2 --msd-stepmode even --growth 6-12-24 --gpu 0 to train on cifar10 data set, but it shows the error

Traceback (most recent call last):
File "main.py", line 445, in
main()
File "main.py", line 139, in main
train(train_loader, model, criterion, optimizer, epoch)
File "main.py", line 212, in train
prec1, prec5, _ = msdnet_accuracy(output, target, input)
File "main.py", line 269, in msdnet_accuracy
top1s.append(tprec1[0])
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to c
onvert a 0-dim tensor to a Python number

Dimension error when I train with images of size 64

Hi Avirambh,

How did you come up with 128 for self.inner_channels; line 418 in msdnet_layers.py?

I tried to run the code with image input size at 64 instead of 32 with 256 self.inner channels but I get an error?

Could you explain how you come up with 128 based on image size 32 from the beginning?

Cheers,
Oushesh

Model on the Imagenet

Hi @avirambh , thanks for your wonderful reproduction work. Could you provide a pytorch model trained on the Imagenet dataset?

Why is the number of output channels of the first convolution in the first layer 32?

According to Appendix A in the paper, for the CIFAR datasets, the number of output channels of the three scales is set to 6, 12 and 24 respectively. However, num_channels is set to 32 in msdnet.py. This means that the number of output channels in the first layer for the three scales is 32, 64 and 128 respectively according to the default growth rate 1-2-4-4. Why is there a difference between the implementation details in the paper and the code?

Question about Dynamic Evaluation

Hi author,
thanks for your work, but I have not understand the dynamic evaluation in origin paper, in this case, i can not implement early exiting from paper.
Can you send me the code about this point? cause I think I can understand paper by code. Thank you very much.

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.