我在Pytorch和Tensorflow上建立了简单的召集网络。
我将重量推向从Pytorch受过预训的层的Tensorflow层,根据stride
,大不相同。 参数
If the stride
is set to 1, the l2 norm between the outputs is approximately same (0.8435), but when the stride
is set to 2 or higher, the l2 norm is significantly high (156.6889).
是否有任何人解释为什么在Pytorch和Tensorflow对stride
的计算有所不同?
# implementation on Pytorch
nn.Conv2d(3, 32, kernel_size=3, padding=1, stride=1, bias=False)
# implementation on Tensorflow
tf.keras.layers.Conv2D(filters=32, kernel_size=(3, 3), strides=1, padding="same", use_bias=False)
-> this results almost same output.
# implementation on Pytorch
nn.Conv2d(3, 32, kernel_size=3, padding=1, stride=2, bias=False)
# implementation on Tensorflow
tf.keras.layers.Conv2D(filters=32, kernel_size=(3, 3), strides=2, padding="same", use_bias=False)
-> this results different output.