<commit_before>import pytest
import numpy as np
from numpy.testing import assert_allclose

from keras import backend as K
from keras.layers import core
from keras.utils.test_utils import layer_test


def test_masking():
    layer_test(core.Masking,
               kwargs={},
               input_shape=(3, 2, 3))


def test_merge():
    from keras.layers import Input, merge
    from keras.models import Model

    # test modes: 'sum', 'mul', 'concat', 'ave', 'cos', 'dot'.
    input_shapes = [(3, 2), (3, 2)]
    inputs = [np.random.random(shape) for shape in input_shapes]

    # test graph API
    for mode in ['sum', 'mul', 'concat', 'ave', 'cos', 'dot']:
        print(mode)
        input_a = Input(shape=input_shapes[0][1:])
        input_b = Input(shape=input_shapes[1][1:])
        merged = merge([input_a, input_b], mode='sum')
        model = Model([input_a, input_b], merged)
        model.compile('rmsprop', 'mse')

        expected_output_shape = model.get_output_shape_for(input_shapes)
        actual_output_shape = model.predict(inputs).shape<commit_msg>Update merge tests<commit_after>import pytest
import numpy as np
from numpy.testing import assert_allclose

from keras import backend as K
from keras.layers import core
from keras.utils.test_utils import layer_test


def test_masking():
    layer_test(core.Masking,
               kwargs={},
               input_shape=(3, 2, 3))


def test_merge():
    from keras.layers import Input, merge
    from keras.models import Model

    # test modes: 'sum', 'mul', 'concat', 'ave', 'cos', 'dot'.
    input_shapes = [(3, 2), (3, 2)]
    inputs = [np.random.random(shape) for shape in input_shapes]

    # test functional API
    for mode in ['sum', 'mul', 'concat', 'ave']:
        print(mode)
        input_a = Input(shape=input_shapes[0][1:])
        input_b = Input(shape=input_shapes[1][1:])
        merged = merge([input_a, input_b], mode=mode)
        model = Model([input_a, input_b], merged)
        model.compile('rmsprop', 'mse')

        expected_output_shape = model.get_output_shape_for(input_shapes)
        actual_output_shape = model.predict(inputs).shape
{'fraction_non_alphanumeric': 0.12833723653395784, 'fraction_numerical': 0.010304449648711944, 'mean_word_length': 3.280561122244489, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6937106', 'n_tokens_mistral': 705, 'n_tokens_neox': 686, 'n_words': 183}