[英]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
中的padding
和keras
中的padding
, 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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.