Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/mnt/sda1/luck/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 433, in __init__
super(Conv2d, self).__init__(
File "/mnt/sda1/luck/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 94, in __init__
raise ValueError("padding='same' is not supported for strided convolutions")
ValueError: padding='same' is not supported for strided convolutions
But tensorflow do support that
teacher = tf.keras.Sequential(
[
tf.keras.Input(shape=(32, 32, 3)),
tf.keras.layers.Conv2D(256, (3, 3), strides=(2, 2), padding='same'),
tf.keras.layers.LeakyReLU(alpha=0.2),
tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=(1, 1), padding='same'),
tf.keras.layers.Conv2D(512, (3, 3), strides=(2,2)),
tf.keras.layers.LeakyReLU(alpha=0.2),
tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=(1, 1), padding='same'),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(10)
],
name='teacher_model'
)
This is the summary
Model: "teacher_model"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d (Conv2D) (None, 16, 16, 256) 7168
_________________________________________________________________
leaky_re_lu (LeakyReLU) (None, 16, 16, 256) 0
_________________________________________________________________
max_pooling2d (MaxPooling2D) (None, 16, 16, 256) 0
_________________________________________________________________
conv2d_1 (Conv2D) (None, 7, 7, 512) 1180160
_________________________________________________________________
leaky_re_lu_1 (LeakyReLU) (None, 7, 7, 512) 0
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 7, 7, 512) 0
_________________________________________________________________
flatten (Flatten) (None, 25088) 0
_________________________________________________________________
dense (Dense) (None, 10) 250890
=================================================================
Total params: 1,438,218
Trainable params: 1,438,218
Non-trainable params: 0
_____________________________
The confusion is why first conv gives 16 instead of 15, and other sencond convlution is working correctly as per the formula.
Also, pytorch does not support strided conv padding same, so I could not even compare.
Confused here please help?