小编Lau*_*Lau的帖子

如何在张量流图中使用另一个库?

我刚读过这篇文章.文章说,tensorflow的resize算法有一些bug.现在我想用scipy.misc.imresize而不是tf.image.resize_images.我想知道实现scipy resize算法的最佳方法是什么.

让我们考虑以下层:

def up_sample(input_tensor, new_height, new_width):
    _up_sampled = tf.image.resize_images(input_tensor, [new_height, new_width])
    _conv = tf.layers.conv2d(_up_sampled, 32, [3,3], padding="SAME")
    return _conv
Run Code Online (Sandbox Code Playgroud)

如何在此图层中使用scipy算法?

编辑:

一个例子可以是这个功能:

input_tensor = tf.placeholder("float32", [10, 200, 200, 8])
output_shape = [32, 210, 210, 8]

def up_sample(input_tensor, output_shape):
    new_array = np.zeros(output_shape)
    for batch in range(input_tensor.shape[0]):
        for channel in range(input_tensor.shape[-1]):
            new_array[batch, :, :, channel] = misc.imresize(input_tensor[batch, :, :, channel], output_shape[1:3])
Run Code Online (Sandbox Code Playgroud)

但显然scipy会引发一个ValueError,即tf.Tensor对象的形状不正确.我读到在tf.Session期间,Tensors可以作为numpy数组访问.如何仅在会话期间使用scipy函数并在创建协议缓冲区时省略执行?

是否有比循环所有批次和渠道更快的方式?

image scipy tensorflow

6
推荐指数
1
解决办法
361
查看次数

标签 统计

image ×1

scipy ×1

tensorflow ×1