Torsorflow相当于Keras函数:UpSampling2D

Jon*_*IAR 6 image-processing convolution keras tensorflow deconvolution

我想使用Keras层:

from keras.layers.convolutional import UpSampling2D
x = UpSampling2D((2, 2))(x)
Run Code Online (Sandbox Code Playgroud)

如何使用原生tensorflow复制此行为?

我无法找到一个等效的函数/图层.

小智 10

假设x是形状(BATCH_SIZE, H, W, C),你可以使用tf.image.resize_nearest_neighbor,这是keras使用的后端实现:

x = tf.image.resize_nearest_neighbor(x, (2*H,2*W))
Run Code Online (Sandbox Code Playgroud)