From ead92bbe653092cde1832ecbaddcef4918254838 Mon Sep 17 00:00:00 2001 From: sunjian <420448185@qq.com> Date: Wed, 3 Aug 2022 09:39:29 +0000 Subject: [PATCH] =?UTF-8?q?ID1117=20=E4=BF=AE=E6=94=B9tf.pad?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cv/FQ-GAN_ID1117_for_TensorFlow/ops.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/TensorFlow/contrib/cv/FQ-GAN_ID1117_for_TensorFlow/ops.py b/TensorFlow/contrib/cv/FQ-GAN_ID1117_for_TensorFlow/ops.py index 12d0f0feb..8085ebcb2 100644 --- a/TensorFlow/contrib/cv/FQ-GAN_ID1117_for_TensorFlow/ops.py +++ b/TensorFlow/contrib/cv/FQ-GAN_ID1117_for_TensorFlow/ops.py @@ -62,7 +62,20 @@ def conv(x, channels, kernel=4, stride=2, pad=0, pad_type='zero', use_bias=True, if pad_type == 'zero': x = tf.pad(x, [[0, 0], [pad_top, pad_bottom], [pad_left, pad_right], [0, 0]]) if pad_type == 'reflect': - x = tf.pad(x, [[0, 0], [pad_top, pad_bottom], [pad_left, pad_right], [0, 0]], mode='REFLECT') + # x = tf.pad(x, [[0, 0], [pad_top, pad_bottom], [pad_left, pad_right], [0, 0]], mode='REFLECT') + + for i in range(pad_top): + j = (i << 1) + 1 + x = tf.concat([x[:, j:j+1, :, :], x], axis=1) + for i in range(pad_bottom): + j = -((i << 1) + 1) + x = tf.concat([x, x[:, j-1:j, :, :]], axis=1) + for i in range(pad_left): + j = (i << 1) + 1 + x = tf.concat([x[:, :, j:j+1, :], x], axis=2) + for i in range(pad_right): + j = -((i << 1) + 1) + x = tf.concat([x, x[:, :, j-1:j, :]], axis=2) if sn : w = tf.get_variable("kernel", shape=[kernel, kernel, x.get_shape()[-1], channels], initializer=weight_init, -- Gitee