【问题标题】:What does it mean when there are four tuples in a tf.pad functiontf.pad 函数中有四个元组是什么意思
【发布时间】:2020-05-15 19:40:34
【问题描述】:

我有这段代码:

    padded_inputs = tf.pad(inputs, [[0, 0], [0, 0], [pad_beg, pad_end], [pad_beg, pad_end]])

这是一个图像。我不明白为什么有四个元组,因为图像具有宽度、高度和三个颜色通道。

【问题讨论】:

    标签: image tensorflow padding object-detection yolo


    【解决方案1】:

    输入数据有 4 个像 [batch_size, number_of_channels, height, width] 这样的元组。所以 tf.pad 没有在前两个 bc 上实现,你只需要填充图像的高度和宽度。有时,频道号也用在最后。

    【讨论】:

    • 谢谢。我也刚刚在 TensorFlow 文档中找到了这个解释:当使用显式填充并且 data_format 为“NHWC”时,这应该是 [[0, 0], [pad_top, pad_bottom], [pad_left, pad_right], [0 , 0]]。当使用显式填充且 data_format 为“NCHW”时,其格式应为 [[0, 0], [0, 0], [pad_top, pad_bottom], [pad_left, pad_right]]。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-02
    • 2016-10-26
    • 1970-01-01
    • 2016-03-04
    相关资源
    最近更新 更多