9333179ad96fad2760221f2b3e2dec31f7c77f40,keras/utils/test_utils.py,,layer_test,#Any#Any#Any#Any#Any#Any#Any#Any#,38

Before Change


    expected_output_shape = layer.get_output_shape_for(input_shape)
    actual_output = model.predict(input_data)
    actual_output_shape = actual_output.shape
    assert expected_output_shape == actual_output_shape
    if expected_output is not None:
        assert_allclose(actual_output, expected_output, rtol=1e-3)

    // test serialization

After Change


            if e is None:
                input_data_shape[i] = np.random.randint(1, 4)
        input_data = (10 * np.random.random(input_data_shape))
        input_data = input_data.astype(input_dtype)
    elif input_shape is None:
        input_shape = input_data.shape

    if expected_output_dtype is None:
        expected_output_dtype = input_dtype

    // instantiation
    layer = layer_cls(**kwargs)

    // test get_weights , set_weights
    weights = layer.get_weights()
    layer.set_weights(weights)

    // test and instantiation from weights
    if "weights" in inspect.getargspec(layer_cls.__init__):
        kwargs["weights"] = weights
        layer = layer_cls(**kwargs)

    // test in functional API
    if fixed_batch_size:
        x = Input(batch_shape=input_shape, dtype=input_dtype)
    else:
        x = Input(shape=input_shape[1:], dtype=input_dtype)
    y = layer(x)
    assert K.dtype(y) == expected_output_dtype

    model = Model(input=x, output=y)
    model.compile("rmsprop", "mse")

    expected_output_shape = layer.get_output_shape_for(input_shape)
    actual_output = model.predict(input_data)
    actual_output_shape = actual_output.shape
    for expected_dim, actual_dim in zip(expected_output_shape,
                                        actual_output_shape):
        if expected_dim is not None:
            assert expected_dim == actual_dim
    if expected_output is not None:
        assert_allclose(actual_output, expected_output, rtol=1e-3)

    // test serialization
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: keras-team/keras
Commit Name: 9333179ad96fad2760221f2b3e2dec31f7c77f40
Time: 2016-12-19
Author: francois.chollet@gmail.com
File Name: keras/utils/test_utils.py
Class Name:
Method Name: layer_test


Project Name: NifTK/NiftyNet
Commit Name: 6d854ec8c54e0eb0a73635f41b0598f2d2231069
Time: 2017-09-01
Author: wenqi.li@ucl.ac.uk
File Name: niftynet/engine/windows_aggregator_base.py
Class Name: ImageWindowsAggregator
Method Name: crop_batch


Project Name: dmlc/gluon-nlp
Commit Name: 2d57a39b24e0a7cbea31debb6117bd14e81c504d
Time: 2018-07-09
Author: xshiab@ust.hk
File Name: tests/unittest/test_batchify.py
Class Name:
Method Name: test_stack_batchify