def upsample_initilizer(dtype=dtypes.float32):
    """Returns an initializer that creates filter for bilinear upsampling.

    Use a transposed convolution layer with ksize = 2n and stride = n to
    perform upsampling by a factor of n.
    """
    if not dtype.is_floating:
        raise TypeError('Cannot create initializer for non-float point type.')

    def _initializer(shape, dtype=dtype, partition_info=None):
        """Initializer function."""
        if not dtype.is_floating:
            raise TypeError('Cannot create initializer for non-floating type.')

        width = shape[0]
        heigh = shape[0]
        f = ceil(width/2.0)
        c = (2 * f - 1 - f % 2) / (2.0 * f)
        bilinear = np.zeros([shape[0], shape[1]])
        for x in range(width):
            for y in range(heigh):
                value = (1 - abs(x / f - c)) * (1 - abs(y / f - c))
                bilinear[x, y] = value
        weights = np.zeros(shape)
        for i in range(shape[2]):
            '''
            the next line of code is correct as given
            [several issues were opened ...]
            we only want to scale each feature,
            so there is no interaction between channels,
            that is why only the diagonal i, i is initialized
            '''
            weights[:, :, i, i] = bilinear

        return weights

    return _initializer
Returns an initializer that creates filter for bilinear upsampling.

    Use a transposed convolution layer with ksize = 2n and stride = n to
    perform upsampling by a factor of n.
    
decoder/fcn.py