コード例 #1
0
def test_convolutional_transpose_original_size_inference_full_padding():
    brick = ConvolutionalTranspose(filter_size=(4, 5), num_filters=10,
                                   num_channels=5, step=(3, 2),
                                   border_mode='full',
                                   image_size=(6, 9))
    brick.allocate()
    assert brick.original_image_size == (13, 13)
    input_ = tensor.tensor4()
    dummy = numpy.empty((4, 5, 6, 9), dtype=theano.config.floatX)
    result = brick.apply(input_).eval({input_: dummy})
    assert result.shape == (4, 10, 13, 13)
コード例 #2
0
def test_convolutional_transpose_original_size_inference_unused_edge():
    brick = ConvolutionalTranspose(filter_size=(3, 3), num_filters=10,
                                   num_channels=5, step=(2, 2),
                                   border_mode=(1, 1), image_size=(4, 4),
                                   unused_edge=(1, 1))
    brick.allocate()
    assert brick.original_image_size == (8, 8)
    input_ = tensor.tensor4()
    dummy = numpy.empty((4, 5, 4, 4), dtype=theano.config.floatX)
    result = brick.apply(input_).eval({input_: dummy})
    assert result.shape == (4, 10, 8, 8)
コード例 #3
0
def test_convolutional_transpose_original_size_inference():
    brick = ConvolutionalTranspose(filter_size=(4, 5), num_filters=10,
                                   num_channels=5, step=(3, 2),
                                   image_size=(6, 9))
    brick.allocate()
    # In x: filter applied 6 times with a step of 3 and filter size of 4
    # means 1 dangling pixel, total original image size of 6 * 3 + 1 == 19.
    # In y: step of 2, applied 9 times, filter size of 5 means 3
    # dangling pixels, so original is 2 * 9 + 3 == 21.
    assert brick.original_image_size == (19, 21)
    input_ = tensor.tensor4()
    dummy = numpy.empty((4, 5, 6, 9), dtype=theano.config.floatX)
    result = brick.apply(input_).eval({input_: dummy})
    assert result.shape == (4, 10, 19, 21)