import tensorflow as tf
import numpy as np
#4x4 grayscale image
input_image = np.array([[
[[1], [2], [3], [4]],
[[5], [6], [7], [8]],
[[9], [10], [11], [12]],
[[13], [14], [15], [16]]
]], dtype=np.float32)
# MaxPooling2D layer
model = tf.keras.Sequential([
tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=(2, 2), padding='valid')
])
output = model.predict(input_image)
print("Input Shape:", input_image.shape)
print("Output Shape:", output.shape)
print("Pooled Output:\n", output[0, :, :, 0])