I would like to use the Keras layer:
from keras.layers.convolutional import UpSampling2D
x = UpSampling2D((2, 2))(x)
How can I replicate this behavior with native tensorflow ?
I can't manage to find an equivalent function/layer.
I would like to use the Keras layer:
from keras.layers.convolutional import UpSampling2D
x = UpSampling2D((2, 2))(x)
How can I replicate this behavior with native tensorflow ?
I can't manage to find an equivalent function/layer.
Assuming x
is of shape (BATCH_SIZE, H, W, C)
, you can use tf.image.resize_nearest_neighbor
, which is the backend implementation used by keras:
x = tf.image.resize_nearest_neighbor(x, (2*H,2*W))
There is tf.keras.layers.UpSampling2D. I'm not exactly sure, but I think the tf.image functions are implemented on the CPU only.