0

Anyone knows the algorithm for pytorch adaptive_avg_pool2d, for example,

adaptive_avg_pool2d(image,[14,14])

so question: I want to do the same in keras neural network, for any give inputs, want to get 14*14 output. Any suggestions?

user10282036
  • 321
  • 2
  • 5
  • 13
  • Possible duplicate of [how to convert pytorch adaptive\_avg\_pool2d method to keras or tensorflow](https://stackoverflow.com/questions/52622518/how-to-convert-pytorch-adaptive-avg-pool2d-method-to-keras-or-tensorflow) – Slimak May 03 '19 at 17:49

1 Answers1

1

I don't think this exists in Keras. You could get the dimension of your input and divide by 14 to get the desired pool_size.

For example if your inputs are 28x28 you can use:

keras.layers.AveragePooling2D(pool_size=(2, 2), strides=None, padding='valid', data_format=None)

Josh Mitton
  • 141
  • 1
  • 3