Hi everyone,

I have been trying out different Fully Convolutional Networks recently, and 
is currently working on Segnet. One of the key point is the way upsampling 
is performed, namely that you keep the pooling indices from the encoder 
part of the network. Fine in theory, but i am struggling with implementing 
this in a good way in theano.

I am aware that pooling indices have been addressed previously here ( Max 
Pooling Indices post), and i thought that worked. But the problem occurs 
when you have an area where all the values are equal. Take a  look at this 
example:

import theano
import numpy as np
import theano.tensor as T

inp =  T.tensor4()
from theano.tensor.signal.pool import pool_2d
f = theano.function([inp], [T.grad(T.sum(max_pool_2d(inp, ds=(2,2))), 
wrt=inp)])

a = np.arange(16).reshape(1, 1, 4, 4)
b = np.ones(16).reshape(1,1,4,4)

a = array([[[[ 0,  1,  2,  3],
         [ 4,  5,  6,  7],
         [ 8,  9, 10, 11],
         [12, 13, 14, 15]]]])

b= array([[[[ 1.,  1.,  1.,  1.],
         [ 1.,  1.,  1.,  1.],
         [ 1.,  1.,  1.,  1.],
         [ 1.,  1.,  1.,  1.]]]])

f(a) = [array([[[[ 0.,  0.,  0.,  0.],
          [ 0.,  1.,  0.,  1.],
          [ 0.,  0.,  0.,  0.],
          [ 0.,  1.,  0.,  1.]]]])]

f(b) = [array([[[[ 1.,  1.,  1.,  1.],
          [ 1.,  1.,  1.,  1.],
          [ 1.,  1.,  1.,  1.],
          [ 1.,  1.,  1.,  1.]]]])]


As you see it works as intended for a, but for b it just outputs ones 
everywhere. I understand that when there is a tie it's not clear which 
value to pick, but it would satosfactory if it just outputted one index 
randomly form the area, like such:

b= array([[[[ 1.,  1.,  1.,  1.],
         [ 1.,  1.,  1.,  1.],
         [ 1.,  1.,  1.,  1.],
         [ 1.,  1.,  1.,  1.]]]])

g = some function that works

g(b) = 
[array([[[[ 0.,  0,  1.,  0.],
          [ 1.,  0.,  0.,  0.],
          [ 0.,  0.,  0.,  0.],
          [ 0.,  1.,  0.,  1.]]]])]


That way, i would at least get the correct number of indices outputted. Has 
anyone done this or got any idea how to solve the problem ?

Thanks in advance, Kristoffer.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to