keras
keras copied to clipboard
keras outputs wrong pool_size in `keras.layers.AveragePooling1D`
The pool_size of keras.layers.AveragePooling1D should be an integer. When I set an integer to keras.layers.AveragePooling1D, then outputs the pool_size of AveragePooling1D layer, I get a tuple. What a surprise😂
repo code:
import keras
layer = keras.layers.AveragePooling1D(pool_size=2)
print(layer.pool_size)
output:
(2,)
Hi,
Thanks for reporting the issue.
AveragePooling1D is subclassing Basepooling class which is same for AveragePooling2D and AveragePooling3D.
Since AveragePooling2D and AveragePooling3D accepts the pool_size in int or tuple, the generic approach would be to return tuple.
Below is the Basepooling logic implementation, and it is not a bug.
https://github.com/keras-team/keras/blob/037ec9f5fc61a53c6e1f4c02b7bf1443429dcd45/keras/layers/pooling/base_pooling.py#L25-L31
Hi, @sachinprasadhs . I think a distinction should be made between the two. I got this parameter to construct a new AveragePooling1D layer, but it doesn't support tuples as pool_size, which causes an error. IMO, If the output of pool_size is a tuple, I think a tuple value of pool_size should also work.
For an int value, you can just use the below code.
import keras
layer = keras.layers.AveragePooling1D(pool_size=2)
print(layer.pool_size[0])
This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.
This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.