Giter Site home page Giter Site logo

msdnet-pytorch's People

Contributors

cpsxhao avatar julicorn avatar kalviny avatar kumasento avatar mileyan 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  avatar  avatar  avatar

msdnet-pytorch's Issues

请问为什么在运行的时候为什么会报 AttributeError: module 'models' has no attribute 'resnet' 这个错误?

D:\software\ana\envs\env1\python.exe C:/Users/Administrator/Desktop/黄高/MSDNet-PyTorch-master/main.py
Traceback (most recent call last):
File "C:/Users/Administrator/Desktop/黄高/MSDNet-PyTorch-master/main.py", line 352, in
main()
File "C:/Users/Administrator/Desktop/黄高/MSDNet-PyTorch-master/main.py", line 62, in main
model = getattr(models, args.arch)(args)
AttributeError: module 'models' has no attribute 'resnet'

Process finished with exit code 1

Reproduce budget batch classification results for CIFAR100

I am trying to reproduce the MSDNet with dynamic evaluation curve of Figure 7b of the paper (budgeted batch classification for CIFAR-100).

I am training the MSDNet as mentioned in the README file.
I then evaluate by:
python main.py --data-root /path/to/cifar100/ --data cifar100 --save /path/to/out/ --arch msdnet --batch-size 64 --epochs 300 --nBlocks 5 --stepmode lin_grow --step 1 --base 1 --nChannels 16 --evalmode dynamic --evaluate-from /path/to/out/save_models/checkpoint_299.pth.tar --use-valid -j 1 --gpu 0

Output log

building network of steps:
[1, 2, 3, 4, 5] 15
 ********************** Block 1  **********************
|		inScales 3 outScales 3 inChannels 16 outChannels 6		|

 ********************** Block 2  **********************
|		inScales 3 outScales 3 inChannels 22 outChannels 6		|

|		inScales 3 outScales 3 inChannels 28 outChannels 6		|

 ********************** Block 3  **********************
|		inScales 3 outScales 3 inChannels 34 outChannels 6		|

|		inScales 3 outScales 3 inChannels 40 outChannels 6		|

|		inScales 3 outScales 2 inChannels 46 outChannels 6		|
|		Transition layer inserted! (max), inChannels 52, outChannels 26	|

 ********************** Block 4  **********************
|		inScales 2 outScales 2 inChannels 26 outChannels 6		|

|		inScales 2 outScales 2 inChannels 32 outChannels 6		|

|		inScales 2 outScales 2 inChannels 38 outChannels 6		|

|		inScales 2 outScales 2 inChannels 44 outChannels 6		|

 ********************** Block 5  **********************
|		inScales 2 outScales 1 inChannels 50 outChannels 6		|
|		Transition layer inserted! (max), inChannels 56, outChannels 28	|

|		inScales 1 outScales 1 inChannels 28 outChannels 6		|

|		inScales 1 outScales 1 inChannels 34 outChannels 6		|

|		inScales 1 outScales 1 inChannels 40 outChannels 6		|

|		inScales 1 outScales 1 inChannels 46 outChannels 6		|

---------------------
FLOPs: 6.86M, Params: 0.30M
---------------------
FLOPs: 14.35M, Params: 0.65M
---------------------
FLOPs: 27.54M, Params: 1.02M
---------------------
FLOPs: 41.71M, Params: 1.49M
---------------------
FLOPs: 58.48M, Params: 2.08M
building network of steps:
[1, 2, 3, 4, 5] 15
 ********************** Block 1  **********************
|		inScales 3 outScales 3 inChannels 16 outChannels 6		|

 ********************** Block 2  **********************
|		inScales 3 outScales 3 inChannels 22 outChannels 6		|

|		inScales 3 outScales 3 inChannels 28 outChannels 6		|

 ********************** Block 3  **********************
|		inScales 3 outScales 3 inChannels 34 outChannels 6		|

|		inScales 3 outScales 3 inChannels 40 outChannels 6		|

|		inScales 3 outScales 2 inChannels 46 outChannels 6		|
|		Transition layer inserted! (max), inChannels 52, outChannels 26	|

 ********************** Block 4  **********************
|		inScales 2 outScales 2 inChannels 26 outChannels 6		|

|		inScales 2 outScales 2 inChannels 32 outChannels 6		|

|		inScales 2 outScales 2 inChannels 38 outChannels 6		|

|		inScales 2 outScales 2 inChannels 44 outChannels 6		|

 ********************** Block 5  **********************
|		inScales 2 outScales 1 inChannels 50 outChannels 6		|
|		Transition layer inserted! (max), inChannels 56, outChannels 28	|

|		inScales 1 outScales 1 inChannels 28 outChannels 6		|

|		inScales 1 outScales 1 inChannels 34 outChannels 6		|

|		inScales 1 outScales 1 inChannels 40 outChannels 6		|

|		inScales 1 outScales 1 inChannels 46 outChannels 6		|

!!!!!! Load train_set_index !!!!!!
*********************
/home/damaskin/MSDNet-PyTorch/adaptive_inference.py:28: UserWarning: torch.range is deprecated in favor of torch.arange and will be removed in 0.5. Note that arange generates values in [start; end), not [start; end].
  probs = torch.exp(torch.log(_p) * torch.range(1, args.nBlocks))
valid acc: 59.020, test acc: 61.500, test flops: 7.09M
*********************
valid acc: 59.960, test acc: 62.080, test flops: 7.44M
*********************
valid acc: 60.700, test acc: 62.870, test flops: 7.90M
*********************
valid acc: 61.660, test acc: 63.500, test flops: 8.36M
*********************
valid acc: 62.700, test acc: 64.050, test flops: 8.93M
*********************
valid acc: 63.900, test acc: 64.850, test flops: 9.66M
*********************
valid acc: 65.040, test acc: 65.670, test flops: 10.53M
*********************
valid acc: 65.760, test acc: 66.400, test flops: 11.32M
*********************
valid acc: 66.920, test acc: 67.130, test flops: 12.34M
*********************
valid acc: 67.740, test acc: 67.800, test flops: 13.32M
*********************
valid acc: 68.600, test acc: 68.560, test flops: 14.48M
*********************
valid acc: 69.500, test acc: 69.330, test flops: 15.67M
*********************
valid acc: 69.880, test acc: 69.980, test flops: 16.88M
*********************
valid acc: 70.420, test acc: 70.310, test flops: 18.25M
*********************
valid acc: 70.820, test acc: 70.770, test flops: 19.61M
*********************
valid acc: 71.460, test acc: 71.150, test flops: 20.90M
*********************
valid acc: 71.840, test acc: 71.530, test flops: 22.28M
*********************
valid acc: 72.260, test acc: 71.970, test flops: 23.62M
*********************
valid acc: 72.860, test acc: 72.150, test flops: 25.03M
*********************
valid acc: 72.880, test acc: 72.360, test flops: 26.24M
*********************
valid acc: 72.880, test acc: 72.530, test flops: 27.46M
*********************
valid acc: 72.960, test acc: 72.610, test flops: 28.95M
*********************
valid acc: 73.080, test acc: 72.650, test flops: 30.14M
*********************
valid acc: 72.840, test acc: 72.900, test flops: 31.26M
*********************
valid acc: 72.780, test acc: 72.920, test flops: 32.32M
*********************
valid acc: 72.840, test acc: 73.070, test flops: 33.44M
*********************
valid acc: 72.640, test acc: 73.020, test flops: 34.26M
*********************
valid acc: 72.720, test acc: 73.160, test flops: 35.17M
*********************
valid acc: 72.740, test acc: 72.940, test flops: 36.09M
*********************
valid acc: 72.660, test acc: 73.030, test flops: 36.87M
*********************
valid acc: 72.700, test acc: 72.980, test flops: 37.61M
*********************
valid acc: 72.600, test acc: 72.920, test flops: 38.28M
*********************
valid acc: 72.580, test acc: 72.870, test flops: 39.01M
*********************
valid acc: 72.460, test acc: 72.680, test flops: 39.59M
*********************
valid acc: 72.400, test acc: 72.660, test flops: 40.20M
*********************
valid acc: 72.300, test acc: 72.660, test flops: 40.80M
*********************
valid acc: 72.220, test acc: 72.620, test flops: 41.28M
*********************
valid acc: 72.160, test acc: 72.580, test flops: 41.80M
*********************
valid acc: 72.160, test acc: 72.580, test flops: 42.16M

The final [test accuracy, budget] pair is [72.58, 0.4 * 10^8] which is not consistent with the results of Figure 7b (as it should have been [~74, 0.4 * 10^8]).
What are the parameters of the 3 MSDNets used in Figure 7b ?

the pretrained model

The tar files inside step=4 and step=7 folder seem corrupt. Could you please check it.

Test when evalmode is dynamic

Sorry, I couldn't understand the function dynamic_evaluate(model, test_loader, val_loader, args) when testing.

if args.evalmode == 'anytime':
            validate(test_loader, model, criterion)
        else:
            dynamic_evaluate(model, test_loader, val_loader, args)
        return

I have obtained models on my dataset. I want to test the model's performance on some images in a dir. However, these images don't have labels. Could I use dynamic (evalmode) or just anytime? Does the test data need labels when chosing dynamic?

Always get "tar: This does not look like a tar archive" when extracting pre-trained models

Hi authors,

Thanks for your great work! I encountered a problem when trying to use your pretrained model to perform evaluations.
I downloaded the tar file from the dropbox link you provided. When I tried to extract it (using command tar -xvf msdnet-step\=4-block\=5.pth.tar, I alway got the following error:

tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors

Could you tell me what I should do? Thanks a lot!

CIFAR-10 results

Hi Kalviny, thanks for your great work! I'm wondering where can I get the CIAFR-10 results of the MSDNet. Thank you!

Version of ImageNet dataset

Which version of ILSVRC (ImageNet) dataset was used for training the MSDNet in this repo? Was it the 2012 one (i.e. the same one as in the original MSDNet paper)?

Configure of step7

Hi, thanks for your work. This code is pretty clean and nice. I want to do get the result of imagenet step7. Can you add the inference command for step 7 imagenet?

The model technically never does 'early exit' ?

Hi, @kalviny thanks a lot for the excellent implementation! It has been extremely helpful for my work.

Reading through validate() in main.py and dynamic_evaluate() in adaptive_inference.py it seems to me that the model processes the entire input in both anytime prediction and budgeted batch classification setting:

In main.py in validate() function in Line 227
output = model(input_var)

In adaptive_inference.py in calc_logit() function in Line 53:
output = self.model(input_var)

which returns an array for results from each block. And then the accuracy calculations for early exit are done in hindsight considering whether the model would have been right or wrong if we consider the output from the intermediate classifiers. Could you please confirm that my interpretation is correct?

Pre_trained model

Your model folder have 2 file index.pth and msdnet-step=4-block=5.pth.tar. Which one I should load to "checkpoint = load_checkpoint(args)"?
I open index.pth, it may not the pretrained weight, while I can't extract msdnet-step=4-block=5.pth.tar.
Thank you

Problem with the meaning of arguments

What do you mean by arguments --step, --stepmode, --use-valid, -j and --base. Also please explain their functions in the formation of blocks of MSDNET ?

How to save the flops.pth of MSDNet in adaptive_inference.py?

Hi author, thanks for your work, but I do not understand the dynamic evaluation in origin paper and how does it works in the code. I can not fine the way to compute and save the flops in your code. Can you send me the code about this point? cause I think I can understand paper by code. Thank you very much.

Model initialization exception

Thanks for sharing your code. I find some anomalous code In msdnet.py#L322.
these three "if branch" will not be excuted in func _init_weights(self, m).

for m in self.blocks:
if hasattr(m, '__iter__'):
for _m in m:
self._init_weights(_m)
else:
self._init_weights(m)
for m in self.classifier:
if hasattr(m, '__iter__'):
for _m in m:
self._init_weights(_m)
else:
self._init_weights(m)
def _init_weights(self, m):
if isinstance(m, nn.Conv2d):
n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
m.weight.data.normal_(0, math.sqrt(2. / n))
elif isinstance(m, nn.BatchNorm2d):
m.weight.data.fill_(1)
m.bias.data.zero_()
elif isinstance(m, nn.Linear):
m.bias.data.zero_()

About reproducing anytime experiment in paper

Hi, thank you very much for this repo! May I ask the performance of step=7/msdnet-step=7-block=5.pth.tar model on Imagenet anytime prediction task?

The result I got is

 * prec@1 62.896 prec@5 84.706
 * prec@1 70.316 prec@5 89.590
 * prec@1 73.000 prec@5 91.230
 * prec@1 73.594 prec@5 91.452
 * prec@1 74.592 prec@5 92.066

---------------------
FLOPs: 615.69M, Params: 8.76M
---------------------
FLOPs: 1436.39M, Params: 20.15M
---------------------
FLOPs: 2283.21M, Params: 31.73M
---------------------
FLOPs: 2967.42M, Params: 41.86M
---------------------
FLOPs: 3253.79M, Params: 62.31M

It is slightly lower than the performance provided in the figure of paper
image

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.