相关疑难解决方法(0)

在Tensorflow中调整tf.image.resize_images等3D数据的大小

我需要调整一些3D数据的大小,例如tf.image.resize_images2d数据的方法。

我当时以为可以尝试tf.image.resize_images在循环和交换轴上运行它,但是我认为必须有一种更简单的方法。简单的最近邻居应该可以。

有任何想法吗?这不是理想的,但是我可以解决数据仅为0或1的情况,并使用类似以下内容:

tf.where(boolMap, tf.fill(data_im*2, 0), tf.fill(data_im*2), 1)
Run Code Online (Sandbox Code Playgroud)

但是我不知道如何得到boolMap。使用tf.while_loop来遍历所有值是否会大大降低性能?我觉得除非有某种自动循环并行化,否则它会在GPU上实现。

数据是大小的张量 [batch_size, width, height, depth, 1]

提前致谢。

注意输出尺寸应为:

[batch_size, width*scale, height*scale, depth*scale, 1]

我想出了这个:

def resize3D(self, input_layer, width_factor, height_factor, depth_factor):
    shape = input_layer.shape
    print(shape)
    rsz1 = tf.image.resize_images(tf.reshape(input_layer, [shape[0], shape[1], shape[2], shape[3]*shape[4]]), [shape[1]*width_factor, shape[2]*height_factor])
    rsz2 = tf.image.resize_images(tf.reshape(tf.transpose(tf.reshape(rsz1, [shape[0], shape[1]*width_factor, shape[2]*height_factor, shape[3], shape[4]]), [0, 3, 2, 1, 4]), [shape[0], shape[3], shape[2]*height_factor, shape[1]*width_factor*shape[4]]), [shape[3]*depth_factor, shape[2]*height_factor])

    return tf.transpose(tf.reshape(rsz2, [shape[0], shape[3]*depth_factor, shape[2]*height_factor, shape[1]*width_factor, shape[4]]), [0, 3, 2, 1, …
Run Code Online (Sandbox Code Playgroud)

3d gpu resize scale tensorflow

5
推荐指数
1
解决办法
4359
查看次数

标签 统计

3d ×1

gpu ×1

resize ×1

scale ×1

tensorflow ×1