def __pad_to_size(self, input, target_shape):
input_shape = tf.shape(input)
difference = target_shape - input_shape
offset = tf.cast(tf.zeros_like(difference, dtype=tf.int16), tf.int32)
padding = tf.concat([tf.expand_dims(difference, axis=1), tf.expand_dims(offset, axis=1)], axis=1)
return tf.pad(input, padding)
评论列表
文章目录