简体   繁体   English

pytorch 相当于 tenserflow 中的 Conv2D,步长为 2,填充为 (1,1)

[英]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) .我有conv1 = nn.Conv2d(3, 16, 3,stride= 2, padding = 1, bias=True, groups=1) i need its corresponding api in tf.keras.layers.Conv2D .我需要在 tf.keras.layers.Conv2D 中对应的tf.keras.layers.Conv2D

Can anyone help me out谁能帮我吗

PS: Here i have a stride of 2 PS:这里我的步幅为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因为很难匹配torch中的paddingkeras中的paddingstride = 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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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