简体   繁体   中英

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

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM