07151a9f75307c7109ffc2bca0aef137a82bcf20,deepBach.py,,skip,#,142

Before Change



                                                              left_metas),
                                                             mode="concat"))
    predictions_right = TimeDistributed(embedding_right)(merge((right_features,

                                                                right_metas),
                                                               mode="concat"))

    predictions_center = merge((central_features,
                                central_metas), mode="concat")

    predictions_center = Dense(num_dense, activation="relu")(predictions_center)
    predictions_center = Dense(num_dense, activation="relu")(predictions_center)

    // dropout
    predictions_left = Dropout(0.2)(predictions_left)
    predictions_right = Dropout(0.2)(predictions_right)
    predictions_center = Dropout(0.2)(predictions_center)

    return_sequences = True
    for k, stack_index in enumerate(range(len(num_units_lstm))):
        if k == len(num_units_lstm) - 1:
            return_sequences = False

        if k > 0:
            // todo difference between concat and sum
            predictions_left_tmp = merge([Activation("relu")(predictions_left), predictions_left_old], mode="sum")
            predictions_right_tmp = merge([Activation("relu")(predictions_right), predictions_right_old], mode="sum")
        else:
            predictions_left_tmp = predictions_left
            predictions_right_tmp = predictions_right

        predictions_left_old = predictions_left
        predictions_right_old = predictions_right
        predictions_left = predictions_left_tmp
        predictions_right = predictions_right_tmp

        predictions_left = LSTM(num_units_lstm[stack_index],
                                return_sequences=return_sequences,
                                name="lstm_left_" + str(stack_index)
                                )(predictions_left)

        predictions_right = LSTM(num_units_lstm[stack_index],
                                 return_sequences=return_sequences,
                                 name="lstm_right_" + str(stack_index)
                                 )(predictions_right)

        // todo dropout here?
        predictions_left = Dropout(0.5)(predictions_left)
        predictions_right = Dropout(0.5)(predictions_right)

    // retain only last input for skip connections
    predictions_left_old = Lambda(lambda t: t[:, -1, :],
                                  output_shape=lambda input_shape: (input_shape[0], input_shape[-1])
                                  )(predictions_left_old)
    predictions_right_old = Lambda(lambda t: t[:, -1, :],
                                   output_shape=lambda input_shape: (input_shape[0], input_shape[-1],)
                                   )(predictions_right_old)
    // concat or sum
    predictions_left = merge([Activation("relu")(predictions_left), predictions_left_old], mode="concat")
    predictions_right = merge([Activation("relu")(predictions_right), predictions_right_old], mode="concat")

    predictions = merge([predictions_left, predictions_center, predictions_right],
                        mode="concat")
    predictions = Dense(num_dense, activation="relu")(predictions)
    pitch_prediction = Dense(num_pitches, activation="softmax",
                             name="pitch_prediction")(predictions)

    model = Model(input=[left_features, central_features, right_features,

After Change


    predictions_left = Dropout(0.2)(TimeDistributed(embedding_left)(Dropout(0.2)(merge((left_features,
                                                                           left_metas),
                                                                          mode="concat"))))
    predictions_right = Dropout(0.2)(TimeDistributed(embedding_right)(Dropout(0.2)(merge((right_features,
                                                                             right_metas),
                                                                            mode="concat"))))

    predictions_center = Dropout(0.2)(merge((central_features,
                                             central_metas), mode="concat"))

    predictions_center = Dense(num_dense, activation="relu")(predictions_center)
    // dropout center
    predictions_center = Dropout(0.2)(predictions_center)
    predictions_center = Dense(num_dense, activation="relu")(predictions_center)

    // dropout

    return_sequences = True
    for k, stack_index in enumerate(range(len(num_units_lstm))):
        if k == len(num_units_lstm) - 1:
            return_sequences = False

        if k > 0:
            // todo difference between concat and sum
            predictions_left_tmp = merge([Activation("relu")(predictions_left), predictions_left_old], mode="sum")
            predictions_right_tmp = merge([Activation("relu")(predictions_right), predictions_right_old], mode="sum")
        else:
            predictions_left_tmp = predictions_left
            predictions_right_tmp = predictions_right

        predictions_left_old = predictions_left
        predictions_right_old = predictions_right
        predictions_left = predictions_left_tmp
        predictions_right = predictions_right_tmp

        predictions_left = LSTM(num_units_lstm[stack_index],
                                return_sequences=return_sequences,
                                name="lstm_left_" + str(stack_index)
                                )(predictions_left)

        predictions_right = LSTM(num_units_lstm[stack_index],
                                 return_sequences=return_sequences,
                                 name="lstm_right_" + str(stack_index)
                                 )(predictions_right)

        // todo dropout here?
        predictions_left = Dropout(0.5)(predictions_left)
        predictions_right = Dropout(0.5)(predictions_right)

    // retain only last input for skip connections
    predictions_left_old = Lambda(lambda t: t[:, -1, :],
                                  output_shape=lambda input_shape: (input_shape[0], input_shape[-1])
                                  )(predictions_left_old)
    predictions_right_old = Lambda(lambda t: t[:, -1, :],
                                   output_shape=lambda input_shape: (input_shape[0], input_shape[-1],)
                                   )(predictions_right_old)
    // todo concat or sum
    predictions_left = merge([Activation("relu")(predictions_left), predictions_left_old], mode="sum")
    predictions_right = merge([Activation("relu")(predictions_right), predictions_right_old], mode="sum")

    predictions = merge([predictions_left, predictions_center, predictions_right],
                        mode="concat")
    predictions = Dense(num_dense, activation="relu")(predictions)
    // todo dropout here ?
    predictions = Dropout(0.2)(predictions)
    pitch_prediction = Dense(num_pitches, activation="softmax",
                             name="pitch_prediction")(predictions)

    model = Model(input=[left_features, central_features, right_features,
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: Ghadjeres/DeepBach
Commit Name: 07151a9f75307c7109ffc2bca0aef137a82bcf20
Time: 2017-01-09
Author: hadjeres.g@gmail.com
File Name: deepBach.py
Class Name:
Method Name: skip