Search code examples
tensorflowkerasneural-networkmax-pooling

How is uneven input handled with same average pooling in keras / tensorflow


Very similar to this question but for average pooling.

The accpeted answer says, that same pooling uses -inf as padding for maxpooling. But what is used for average pooling. Do they use just 0?


Solution

  • Ok I just testef it out myself.

    np.set_printoptions(threshold=np.nan)
    x = np.array([[[3.0,3.0,3.0],[3.0,3.0,3.0]]])
    x = x.reshape(1,2,3,1)
    sess = tf.Session()
    K.set_session(sess)
    b = K.constant(x)
    b = AveragePooling2D(pool_size=(2, 2), padding="same")(b)
    b = tf.Print(b,[b])
    sess.run(b)
    

    This returns the tensor [[[[3][3]]]] so it has to pad with 0.