Ejemplo n.º 1
0
def test_sub_pixel_upscaling():
    num_samples = 2
    num_row = 16
    num_col = 16

    for scale_factor in [2, 3, 4]:
        input_data = np.random.random(
            (num_samples, 4 * (scale_factor**2), num_row, num_col))

        if K.image_data_format() == 'channels_last':
            input_data = input_data.transpose((0, 2, 3, 1))

        input_tensor = K.variable(input_data)
        expected_output = K.eval(
            KC.depth_to_space(input_tensor, scale=scale_factor))

        layer_test(convolutional.SubPixelUpscaling,
                   kwargs={'scale_factor': scale_factor},
                   input_data=input_data,
                   expected_output=expected_output,
                   expected_output_dtype=K.floatx())
def test_sub_pixel_upscaling(scale_factor):
    num_samples = 2
    num_row = 16
    num_col = 16
    input_dtype = K.floatx()

    nb_channels = 4 * (scale_factor**2)
    input_data = np.random.random((num_samples, nb_channels, num_row, num_col))
    input_data = input_data.astype(input_dtype)

    if K.image_data_format() == "channels_last":
        input_data = input_data.transpose((0, 2, 3, 1))

    input_tensor = K.variable(input_data)
    expected_output = K.eval(
        KC.depth_to_space(input_tensor, scale=scale_factor))

    layer_test(
        SubPixelUpscaling,
        kwargs={"scale_factor": scale_factor},
        input_data=input_data,
        expected_output=expected_output,
        expected_output_dtype=K.floatx(),
    )
Ejemplo n.º 3
0
 def call(self, x, mask=None):
     y = KC.depth_to_space(x, self.scale_factor, self.data_format)
     return y