Home > OS >  pytorch equivalent of Conv2D in tenserflow with stride of 2 and padding of (1,1)
pytorch equivalent of Conv2D in tenserflow with stride of 2 and padding of (1,1)

Time:04-26

I have conv1 = nn.Conv2d(3, 16, 3,stride= 2, padding = 1, bias=True, groups=1) . i need its corresponding api in tf.keras.layers.Conv2D.

Can anyone help me out

PS : Here i have a stride of 2

CodePudding user response:

I have found the solution , hope this might be help full to others as well . As it was difficult to match padding in torch and padding in keras with stride = 2

X = Input(shape = (10,10,3))
X1 = ZeroPadding2D(padding=(1,1), input_shape=(10, 10, 3), data_format="channels_last")(X)
conv1 = Conv2D(16, 3,  padding = 'valid', strides = (2,2))(X1)
  • Related