warmspringwinds / pytorch-segmentation-detection

Image Segmentation and Object Detection in Pytorch
MIT License
746 stars 170 forks source link

Change call to .apply() #10

Closed prlz77 closed 6 years ago

prlz77 commented 6 years ago

Great script!

Btw, .apply() uses .children(), which may lead to skip convolutional layers in submodules. I replaced it for modules() for if you want to change it.

warmspringwinds commented 6 years ago

Hi @prlz77

Thank you so much for your contribution -- I am actually working on this right now :)

I have just checked out the source for .apply(): http://pytorch.org/docs/master/_modules/torch/nn/modules/module.html

Yes, you are right that it traverses .children() but it also calls .apply() for each of them, meaning that it will also reach submodules. Can you give an example when this approach might not work?

Thank you.

prlz77 commented 6 years ago

Sorry, you are right! I need the .modules() but the fault is in my side.

My apologies to make you lose your time!

warmspringwinds commented 6 years ago

@prlz77 No worries at all :)

This flops counting module is new -- feel free to contribute more or leave your suggestions

Thank you.