Lasagne / Recipes

Lasagne recipes: examples, IPython notebooks, ...
MIT License
914 stars 418 forks source link

ImageNet Pretrained Network CPU/GPU #32

Closed NetzerEitan closed 8 years ago

NetzerEitan commented 8 years ago

Hi all,

I tried the great example of ImageNet Pretrained Network (VGG_S).ipynb. https://github.com/Lasagne/Recipes/blob/master/examples/ImageNet%20Pretrained%20Network%20(VGG_S).ipynb

With GPU I get the same result in the tutorial. But with a CPU I am getting different results.

For example instead of "German Shepherd" the net "thinks" its "Border terrier"

Why is that? Can I fix it?

Best Eitan

ebenolson commented 8 years ago

I assume you replaced the Conv2DDNNLayer with a Conv2DLayer to run on CPU. In this case, you need to flip the filter kernels, because Conv2DDNNLayer by default performs a correlation rather than a convolution.

try running this after loading the parameters:

for layer in net.values():
    if type(layer) == ConvLayer:
        W = layer.W.get_value()
        W = W[:, :, ::-1, ::-1]
        layer.W.set_value(W)
NetzerEitan commented 8 years ago

Thank

I tried as you suggested, but it did not help.

ebenolson commented 8 years ago

I had a typo, should be W = W[:, :, ::-1, ::-1].

NetzerEitan commented 8 years ago

Yes I noticed tried both...

ebenolson commented 8 years ago

Have you made any other changes to the code? What versions of Theano and Lasagne are you using?

NetzerEitan commented 8 years ago

No, I have not changed anything.

theano.version = 0.7.0.dev-15c90dd36c95ea2989a2c0085399147d15a6a477 lasagne.version = 0.2.dev1

ebenolson commented 8 years ago

Hmm.. it works for me: https://gist.github.com/ebenolson/e41398fe067d42fc16d8, if you still see a different result try running the Lasagne test suite, perhaps there is something wrong with your installation.

NetzerEitan commented 8 years ago

Thank you very much I will try.