resize.py 文件源码

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

项目:dataset 作者: analysiscenter 项目源码 文件源码
def subpixel_conv(inputs, factor=2, name='subpixel', data_format='channels_last', **kwargs):
    """ Resize input tensor with subpixel convolution (depth to space operation)

    Parameters
    ----------
    inputs : tf.Tensor
        a tensor to resize
    factor : int
        upsampling factor
    name : str
        scope name
    data_format : {'channels_last', 'channels_first'}
        position of the channels dimension

    Returns
    -------
    tf.Tensor
    """
    dim = inputs.shape.ndims - 2

    _, channels = _calc_size(inputs, factor, data_format)
    layout = kwargs.get('layout', 'cna')
    kwargs['filters'] = channels*factor**dim

    with tf.variable_scope(name):
        x = conv_block(inputs, layout, kernel_size=1, name='conv', data_format=data_format, **kwargs)
        x = depth_to_space(x, block_size=factor, name='d2s', data_format=data_format)
    return x
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号