layers.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:tefla 作者: openAGI 项目源码 文件源码
def crop_and_concat(inputs1, inputs2, name='crop_concat'):
    """Concates two features maps
      concates different sizes feature maps cropping the larger map
      concatenation across output channels

    Args:
        inputs1: A `Tensor`
        inputs2: A `Tensor`

    Returns:
       concated output tensor
    """
    with tf.name_scope(name):
        inputs1_shape = tf.shape(inputs1)
        inputs2_shape = tf.shape(inputs2)
        # offsets for the top left corner of the crop
        offsets = [0, (inputs1_shape[1] - inputs2_shape[1]) // 2,
                   (inputs1_shape[2] - inputs2_shape[2]) // 2, 0]
        size = [-1, inputs2_shape[1], inputs2_shape[2], -1]
        inputs1_crop = tf.slice(inputs1, offsets, size)
        return tf.concat([inputs1_crop, inputs2], axis=3)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号