Image over Image convolution in Tensorflow

前端 未结 1 498
无人共我
无人共我 2021-01-29 02:57

Assume, I have two set of images, A and B, each 11X5x5x3, where 11 is a number of examples and 5x5x3 is an image dimension.
Is there an easy way in Tensorflow to apply convo

相关标签:
1条回答
  • I am not sure that is what you need because it is not really batch mode but you could use a map function :

    A = tf.placeholder(dtype=tf.float32, shape=[None, 5, 5, 3])
    B = tf.placeholder(dtype=tf.float32, shape=[None, 5, 5, 3])
    
    output = tf.map_fn(
        lambda inputs : tf.nn.conv2d(
            tf.expand_dims(inputs[0], 0),  # H,W,C -> 1,H,W,C
            tf.expand_dims(inputs[1], 3),  # H,W,C -> H,W,C,1
            strides=[1,1,1,1],
            padding="SAME"
        ),  # Result of conv is 1,H,W,1
       elems=[A,B],
       dtype=tf.float32
    )
    final_output = output[:, 0, :, :, 0]  # B,1,H,W,1 -> B,H,W
    

    Performance will depend on how the tiny separate convolutions will be parallelized I guess.

    0 讨论(0)
提交回复
热议问题