I have a layer which is defined as following
import tensorflow.keras.layers as layers
avg_pool = layers.AveragePooling1D(pool_size=2)
Is there a way to print the details of this layer? (in this case it would be printing the pool_size
)?
I cannot use summary on this layer as it gives me
AttributeError: 'AveragePooling1D' object has no attribute 'summary'
The .summary
is available for model
class and not layer
. That's why you can't do avg_pool.summary()
. But you can wrap it into model class.
avg_pool = layers.AveragePooling1D(pool_size=2)
avg_pool.pool_size
(2,)
# init model
model = keras.Sequential([avg_pool])
# run on some dummy tensor to build the model
x = np.array([1., 2., 3., 4., 5.])
x = np.reshape(x, [1, 5, 1])
_ = model(x)
# print summary
model.summary() # OK