PavlosMelissinos / enet-keras

A keras implementation of ENet (abandoned for the foreseeable future)
MIT License
115 stars 46 forks source link

MaxUnpooling in the decoder #4

Closed copaah closed 7 years ago

copaah commented 7 years ago

Have you tried to implement the MaxUnpooling operation that the original ENet uses instead of using the UpSampling Layer?

PavlosMelissinos commented 7 years ago

Nice catch!

First of all, I tend to agree with Geoff Hinton who said that it's a disaster that pooling works in CNNs.

However, I've tried implementing unpooling on another project that is currently not public. Making it work on keras though was too dirty and I don't think it's that effective so I'm not sure it's worth the effort.

Instead of using that, I've been playing with the idea of dilated convolutions instead of pooling and subpixel convolutions instead of unpooling/upsampling/deconvolution operations.

However, having the original setup is important for result reproduction during evaluation so I'll consider pushing an alternative version of enet with the original unpooling operation if you'd be interested in that (I have to warn you that it's ugly though).

copaah commented 7 years ago

I'd be very much interested in seeing your solution. I've tried it myself, mainly using ideas from https://github.com/tensorflow/tensorflow/issues/2169, but I never got it to work properly.

PavlosMelissinos commented 7 years ago

Ok, gist is up with just the unpooling-related code so you can have a look or add it to your code until I find some time to add it to the project. It's been a while since I wrote that and can definitely be improved so feel free to ask anything and do whatever you want with it.

PavlosMelissinos commented 7 years ago

Thanks for the 🎉 ! Check again, I've added a few lines to a different file to demonstrate usage.

PavlosMelissinos commented 7 years ago

Any luck @MarcoDalFarra? Did it work?

copaah commented 7 years ago

I haven't tried it yet. Right now I'm looking into this new paper: https://arxiv.org/abs/1704.08545v1 - but I will let you know, when I'm giving it a go. Perhaps in the coming week :)

copaah commented 7 years ago

So I got it to work. I still need to run a few tests, but it seems like the predictions do indeed get sharper boundaries for the objects as expected. At least compared to my old approach, which was to always unpool by placing the max element in the top left corner. I haven't tested the performance implications, but that is on my next to do. Thank you very much for your help!

PavlosMelissinos commented 7 years ago

Nice! I'm glad it worked. :)

On May 16, 2017 6:53 PM, "MarcoDalFarra" notifications@github.com wrote:

So I got it to work. I still need to run a few tests, but it seems like the predictions do indeed get sharper boundaries for the objects as expected. At least compared to my old approach, which was to always unpool by placing the max element in the top left corner. I haven't tested the performance implications, but that is on my next to do. Thank you very much for your help!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PavlosMelissinos/enet-keras/issues/4#issuecomment-301827301, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXtwRkoHa0d4XsHfPinobmPWAGcfXv5ks5r6cZggaJpZM4NRlCQ .

PavlosMelissinos commented 7 years ago

A (slightly nicer) version of the network with unpooling is now available (src/models/enet_unpooling)!

  1. Using tf.nn.max_pool_with_argmax to get both the values and the indices at once instead of splitting the tasks to two different layers.
  2. Unpooling2D using tf.scatter_nd instead of UpSampling2D and tf.where.
mrgloom commented 6 years ago

Looks like this trick can be used to get max pooling indices: https://github.com/keras-team/keras/blob/4f2e65c385d60fa87bb143c6c506cbe428895f44/examples/mnist_swwae.py#L90

PavlosMelissinos commented 6 years ago

This project has been on hold for quite some time but that's good to know, thanks!