GithubHelp home page GithubHelp logo

Comments (6)

ebenolson avatar ebenolson commented on June 2, 2024

Thanks for the report. I have a feeling this was caused by recent changes to the Pool2DLayer API. Unfortunately I won't be able to investigate further for a few days, but if you have a chance try adding ignore_border=False to the arguments for each PoolLayer call.

from recipes.

pfeodrippe avatar pfeodrippe commented on June 2, 2024

It worked, man \o/, thanks! Just adding ignore_border=False to the pool layers as you said just made the code work perfectly

And OMG, what a awesome library, its concept is beautiful... just beautiful =)

net = {}
net['input'] = InputLayer((None, 3, 224, 224))
net['conv1'] = ConvLayer(net['input'], num_filters=96, filter_size=7, stride=2)
net['norm1'] = NormLayer(net['conv1'], alpha=0.0001) # caffe has alpha = alpha * pool_size
net['pool1'] = PoolLayer(net['norm1'], pool_size=3, stride=3, ignore_border=False)
net['conv2'] = ConvLayer(net['pool1'], num_filters=256, filter_size=5)
net['pool2'] = PoolLayer(net['conv2'], pool_size=2, stride=2, ignore_border=False)
net['conv3'] = ConvLayer(net['pool2'], num_filters=512, filter_size=3, pad=1)
net['conv4'] = ConvLayer(net['conv3'], num_filters=512, filter_size=3, pad=1)
net['conv5'] = ConvLayer(net['conv4'], num_filters=512, filter_size=3, pad=1)
net['pool5'] = PoolLayer(net['conv5'], pool_size=3, stride=3, ignore_border=False)
net['fc6'] = DenseLayer(net['pool5'], num_units=4096)
net['drop6'] = DropoutLayer(net['fc6'], p=0.5)
net['fc7'] = DenseLayer(net['drop6'], num_units=4096)
net['drop7'] = DropoutLayer(net['fc7'], p=0.5)
net['fc8'] = DenseLayer(net['drop7'], num_units=1000, nonlinearity=lasagne.nonlinearities.softmax)
output_layer = net['fc8']

from recipes.

f0k avatar f0k commented on June 2, 2024

I have a feeling this was caused by recent changes to the Pool2DLayer API.

Right... we should update it!

Just adding ignore_border=False to the pool layers as you said just made the code work perfectly

Note that you will still get wrong predictions when replacing a Conv2DDNNLayer with a ConvLayer! The Conv2DDNNLayer has a flip_filters keyword argument which defaults to False: http://lasagne.readthedocs.org/en/latest/modules/layers/dnn.html#lasagne.layers.dnn.Conv2DDNNLayer.
So by default, it will compute a correlation, not a convolution. The Conv2DLayer does not have this keyword argument, it will always compute a convolution. To fix this, you will need to explicitly flip the convolution filters after loading everything:

for k, layer in net:
    if k.startswith('conv'):
        layer.W.set_value(np.asarray(layer.W.get_value())[:,:,::-1,::-1])

from recipes.

f0k avatar f0k commented on June 2, 2024

Right... we should update it!

While we're at it, the following should change as well:

# We need a recent theano version for this to work
assert theano.__version__ >= '0.7.0.dev-512c2c16ac1c7b91d2db3849d8e7f384b524d23b'

class AveragePool2DLayer(lasagne.layers.MaxPool2DLayer):

For one, the version check doesn't work this way, because SHA1 sums are not following any particular order. The next commit's version string may be (lexicographically) smaller.

And secondly, the subclass isn't needed any more since you added the Pool2DLayer.

from recipes.

ebenolson avatar ebenolson commented on June 2, 2024

For one, the version check doesn't work this way, because SHA1 sums are not following any particular order. The next commit's version string may be (lexicographically) smaller.

Yeah, I realized this during the Theano version debate but hadn't got around to fixing it yet. As far as I know, there's no way to actually version test Theano reliably, right?

from recipes.

f0k avatar f0k commented on June 2, 2024

As far as I know, there's no way to actually version test Theano reliably, right?

Correct. We just have to rely on people following Lasagne's installation instructions. I guess we shouldn't do additional version checks in Recipes then, unless a particular Recipe requires a more recent version of Theano than Lasagne. (In that case, if possible, I'd suggest to check for the presence of the required feature, rather than the version string.)

from recipes.

Related Issues (20)

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.