I created the following CNN model:
model = tf.keras.Sequential([
tf.keras.layers.Conv2D(16, 4, strides=4, input_shape=(12,12,1)),
tf.keras.layers.SeparableConv2D( 1, 3, depth_multiplier=1),
tf.keras.layers.Conv2D(8, 1, activation='relu'),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(2)
])
print(model.summary())
My intension was that the seperableConv2D layer will create a single 3x3 kernel that will operate separately on each one of the 16 3x3 input images and will result in 16 single numbers. However, the result was that it learned 3x3x16 kernel and resulted in a single number. After reading the explanation regarding Seperable2D in here, I understood that it is training different 3x3 for each one of the channels (which I could live with) but then merges these 16 numbers to 1. My questions are:
- Is there a way (using SeperableConv2 or any other way) to avoid the last step of going from 1X1X16 to 1X1X1?
- Is there a way to train a single 3x3 kernel that will work on all 16 channels separately and create 1x1x16 output?