我想使用Keras层: from keras.layers.convolutional import UpSampling2D x = UpSampling2D((2, 2))(x) 我应该如何使用TensorFlow原生功能复制这种行为呢?我找不到相应的函数/层。
假设x的形状为(BATCH_SIZE, H, W, C),您可以使用tf.image.resize_nearest_neighbor,这是Keras使用的后端实现:x = tf.image.resize_nearest_neighbor(x, (2*H,2*W))