What does TensorFlow's `conv2d_transpose()` operation do?

后端 未结 6 637
悲&欢浪女
悲&欢浪女 2021-01-30 04:07

The documentation for the conv2d_transpose() operation does not clearly explain what it does:

The transpose of conv2d.

This opera

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 04:51

    One application for conv2d_transpose is upscaling, here is an example that explains how it works:

    a = np.array([[0, 0, 1.5],
                  [0, 1, 0],
                  [0, 0, 0]]).reshape(1,3,3,1)
    
    filt = np.array([[1, 2],
                     [3, 4.0]]).reshape(2,2,1,1)
    
    b = tf.nn.conv2d_transpose(a,
                               filt,
                               output_shape=[1,6,6,1],
                               strides=[1,2,2,1],
                               padding='SAME')
    
    print(tf.squeeze(b))
    
    tf.Tensor(
    [[0.  0.  0.  0.  1.5 3. ]
     [0.  0.  0.  0.  4.5 6. ]
     [0.  0.  1.  2.  0.  0. ]
     [0.  0.  3.  4.  0.  0. ]
     [0.  0.  0.  0.  0.  0. ]
     [0.  0.  0.  0.  0.  0. ]], shape=(6, 6), dtype=float64)
    

提交回复
热议问题