33ff9dbce230068e65dedb2f41a00c39c70bef93,tests/keras/layers/test_wrappers.py,,test_Bidirectional,#,80

Before Change


            // test with Sequential model
            model = Sequential()
            model.add(wrappers.Bidirectional(rnn(3), merge_mode=mode, input_shape=(3, 2)))
            model.add(core.Activation("sigmoid"))
            model.compile(loss="mse", optimizer="sgd")
            model.fit(x, y, nb_epoch=1, batch_size=5)

After Change


    nb_sample = 1
    dim = 2
    timesteps = 2
    for mode in ["sum", "concat"]:
        x = np.random.random((nb_sample, timesteps, dim))
        output_dim = 2 if mode == "concat" else 1
        y = np.random.random((nb_sample, output_dim))

        // test with Sequential model
        model = Sequential()
        model.add(wrappers.Bidirectional(rnn(1),
                                         merge_mode=mode, input_shape=(timesteps, dim)))
        model.compile(loss="mse", optimizer="sgd")
        model.fit(x, y, nb_epoch=1, batch_size=1)

        // test config
        model.get_config()
        model = model_from_json(model.to_json())
        model.summary()

        // test stacked bidirectional layers
        model = Sequential()
        model.add(wrappers.Bidirectional(rnn(1, return_sequences=True),
                                         merge_mode=mode, input_shape=(timesteps, dim)))
        model.add(wrappers.Bidirectional(rnn(1), merge_mode=mode))
        model.compile(loss="mse", optimizer="sgd")
        model.fit(x, y, nb_epoch=1, batch_size=1)

        // test with functional API
        input = Input((timesteps, dim))
        output = wrappers.Bidirectional(rnn(1), merge_mode=mode)(input)
        model = Model(input, output)
        model.compile(loss="mse", optimizer="sgd")
        model.fit(x, y, nb_epoch=1, batch_size=1)


if __name__ == "__main__":
    pytest.main([__file__])
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: keras-team/keras
Commit Name: 33ff9dbce230068e65dedb2f41a00c39c70bef93
Time: 2016-08-17
Author: francois.chollet@gmail.com
File Name: tests/keras/layers/test_wrappers.py
Class Name:
Method Name: test_Bidirectional


Project Name: keras-team/autokeras
Commit Name: 7f30b2403fadc4eaad48ceaf6154a626f477f8c8
Time: 2018-05-26
Author: jin@tamu.edu
File Name: autokeras/generator.py
Class Name: DefaultClassifierGenerator
Method Name: generate


Project Name: keras-team/autokeras
Commit Name: 4b83c1070cebd0d996ba2cc69779dcb66d5d0032
Time: 2018-05-29
Author: jhfjhfj1@gmail.com
File Name: autokeras/generator.py
Class Name: DefaultClassifierGenerator
Method Name: generate