p2irc / deepplantphenomics

Deep learning for plant phenotyping.
GNU General Public License v2.0
135 stars 46 forks source link

Fix pooling layer output size #20

Closed donovanlavoie closed 5 years ago

donovanlavoie commented 5 years ago

This fixes a small bug in the calculation of output sizes for pooling layers. The way they were previously being calculated essentially assumed no padding (equivalent to giving padding='VALID' to tf.nn.pool). Our actual calls to tf.nn.max_pool (and .avg_pool) used padding='SAME', which pads inputs so that kernel size doesn't matter in the output size calculation.

Some test cases were added to check these based on using 2x2 and 3x3 pooling on a 5x5 input image. The 2x2 filter with strides of 2 and 1 were failing before with output sizes of 2 and 4 instead of the actual sizes of 3 and 5. The 3x3 filter with a stride of 3 happened to pass before the fix because of how output size calculation changed based on even and odd filter sizes.