94dbc3042f5a85b399f5ce2859d4e8fbafd235b9,tests/keras/backend/backend_test.py,,check_two_tensor_operation,#Any#Any#Any#Any#,37

Before Change


def check_two_tensor_operation(function_name, x_input_shape,
                               y_input_shape, backend_list, **kwargs):
    xval = np.random.random(x_input_shape) - 0.5
    x_list = [k.variable(xval) for k in backend_list]

    yval = np.random.random(y_input_shape) - 0.5

    y_list = [k.variable(yval) for k in backend_list]

    z_list = []
    for x, y, k in zip(x_list, y_list, backend_list):
        z_list.append(k.eval(getattr(k, function_name)(x, y, **kwargs)))

    for i in range(len(z_list) - 1):
        assert z_list[i].shape == z_list[i + 1].shape
        assert_allclose(z_list[i], z_list[i + 1], atol=1e-05)
        if hasattr(z_list[i], "_keras_shape"):

After Change


            assert z._keras_shape == z.shape
        z_list += [z]

    for (z1, z2) in zip(z_list[1:], z_list[:-1]):
        assert z1.shape == z2.shape
        assert_allclose(z1, z2, atol=1e-05)


def check_cross_entropy_with_valid_probability_distribution():
    xval = np.asarray([[0.26157712, 0.0432167], [-0.43380741, 0.30559841],
                       [0.20225059, -0.38956559], [-0.13805378, 0.08506755]], dtype=np.float32)
    xtf = KTF.variable(xval)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: keras-team/keras
Commit Name: 94dbc3042f5a85b399f5ce2859d4e8fbafd235b9
Time: 2017-07-06
Author: me@taehoonlee.com
File Name: tests/keras/backend/backend_test.py
Class Name:
Method Name: check_two_tensor_operation


Project Name: facebookresearch/pythia
Commit Name: 2f337387d6759627bae60284e7fa612268580724
Time: 2020-09-15
Author: vedanujg@gmail.com
File Name: mmf/models/mmf_transformer.py
Class Name: MMFTransformerEmbeddings
Method Name: forward


Project Name: keras-team/keras
Commit Name: 94dbc3042f5a85b399f5ce2859d4e8fbafd235b9
Time: 2017-07-06
Author: me@taehoonlee.com
File Name: tests/keras/backend/backend_test.py
Class Name:
Method Name: check_single_tensor_operation