Tensorflow 等效于 Keras 函数:UpSampling2D
Tensorflow equivalent of the Keras function: UpSampling2D
我想使用 Keras 层:
from keras.layers.convolutional import UpSampling2D
x = UpSampling2D((2, 2))(x)
如何使用本机 tensorflow 复制此行为?
我找不到等效项 function/layer。
假设x
的形状是(BATCH_SIZE, H, W, C)
,可以使用tf.image.resize_nearest_neighbor
,这是keras使用的后端实现:
x = tf.image.resize_nearest_neighbor(x, (2*H,2*W))
有tf.keras.layers.UpSampling2D。我不太确定,但我认为 tf.image 功能仅在 CPU 上实现。
我想使用 Keras 层:
from keras.layers.convolutional import UpSampling2D
x = UpSampling2D((2, 2))(x)
如何使用本机 tensorflow 复制此行为?
我找不到等效项 function/layer。
假设x
的形状是(BATCH_SIZE, H, W, C)
,可以使用tf.image.resize_nearest_neighbor
,这是keras使用的后端实现:
x = tf.image.resize_nearest_neighbor(x, (2*H,2*W))
有tf.keras.layers.UpSampling2D。我不太确定,但我认为 tf.image 功能仅在 CPU 上实现。