Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow equivalent of the Keras function: UpSampling2D

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.

like image 655
Jonathan DEKHTIAR Avatar asked Oct 10 '17 22:10

Jonathan DEKHTIAR


1 Answers

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))
like image 178
amirbar Avatar answered Oct 20 '22 22:10

amirbar