Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use L2 pooling in Tensorflow?

I am trying to implement one CNN architecture that uses L2 pooling. The reference paper particularly argues that L2 pooling was better than max pooling, so I would like to try L2 pooling after the activation function.

However, Tensorflow seems to provide only tf.nn.avg_pool / tf.nn.max_pooling / tf.nn.max_pool_with_argmax.

Is there a way to implement L2 pooling in Tensorflow?

conv = tf.....
h = tf.nn.tanh(conv)
p = tf.pow(tf.nn.ave_pool(tf.pow(h,2)), 0.5)

Will this be equivalent? Will this work well in terms of backpropagation?

like image 470
YW P Kwon Avatar asked Nov 09 '22 16:11

YW P Kwon


1 Answers

For those who may wonder, when I tried as in Yaroslav Bulatov's response, I could see better performance:

tf.sqrt(tf.nn.ave_pool(tf.square(h))
like image 60
YW P Kwon Avatar answered Nov 14 '22 22:11

YW P Kwon