Beispiel #1
0
        upsamp_X = T.nnet.abstract_conv.bilinear_upsampling(X, pool_factor)
        Y = conv(upsamp_X)
        return Y

    return upsample


if __name__ == "__main__":
    from theano_toolkit.parameters import Parameters
    P = Parameters()
    image_size = 10
    rfield_size = 5
    input_size = 1
    X = T.as_tensor_variable(
        np.random.randn(1, input_size, 4, 4).astype(np.float32))
    P.W = conv_weight_init(2, 1, 5)
    P.b = np.zeros(2)
    W = P.W
    b = P.b.dimshuffle('x', 0, 'x', 'x')

    upsamp_X_1 = T.zeros(
        (X.shape[0], X.shape[1], 2 * X.shape[2], 2 * X.shape[3]))
    upsamp_X_1 = T.set_subtensor(upsamp_X_1[:, :, ::2, ::2], X)
    upsamp_X_1 = T.inc_subtensor(upsamp_X_1[:, :, 1:-1:2, ::2],
                                 0.5 * (X[:, :, :-1] + X[:, :, 1:]))
    upsamp_X_1 = T.inc_subtensor(upsamp_X_1[:, :, ::2, 1:-1:2],
                                 0.5 * (X[:, :, :, :-1] + X[:, :, :, 1:]))
    upsamp_X_1 = T.inc_subtensor(
        upsamp_X_1[:, :, 1:-1:2, 1:-1:2],
        0.25 * (X[:, :, :-1, :-1] + X[:, :, 1:, :-1] + X[:, :, :-1, 1:] +
                X[:, :, 1:, 1:]))