Esempio n. 1
0
    '''
    filters = input._keras_shape[-1]  # channel_axis = -1 for TF

    se = GlobalAveragePooling1D()(input)
    se = Reshape((1, filters))(se)
    se = Dense(filters // 16,
               activation='relu',
               kernel_initializer='he_normal',
               use_bias=False)(se)
    se = Dense(filters,
               activation='sigmoid',
               kernel_initializer='he_normal',
               use_bias=False)(se)
    se = multiply([input, se])
    return se


if __name__ == "__main__":
    model = generate_model_2()

    train_model(model,
                DATASET_INDEX,
                dataset_prefix='ozone',
                epochs=600,
                batch_size=128)

    evaluate_model(model,
                   DATASET_INDEX,
                   dataset_prefix='ozone',
                   batch_size=128)
Esempio n. 2
0
    '''
    filters = input._keras_shape[-1]  # channel_axis = -1 for TF

    se = GlobalAveragePooling1D()(input)
    se = Reshape((1, filters))(se)
    se = Dense(filters // 16,
               activation='relu',
               kernel_initializer='he_normal',
               use_bias=False)(se)
    se = Dense(filters,
               activation='sigmoid',
               kernel_initializer='he_normal',
               use_bias=False)(se)
    se = multiply([input, se])
    return se


if __name__ == "__main__":
    model = generate_model_2()

    train_model(model,
                DATASET_INDEX,
                dataset_prefix='eeg2_attention',
                epochs=500,
                batch_size=128)

    evaluate_model(model,
                   DATASET_INDEX,
                   dataset_prefix='eeg2_attention',
                   batch_size=128)
Esempio n. 3
0
    Returns: a keras tensor
    '''
    filters = input._keras_shape[-1]  # channel_axis = -1 for TF

    se = GlobalAveragePooling1D()(input)
    se = Reshape((1, filters))(se)
    se = Dense(filters // 16,
               activation='relu',
               kernel_initializer='he_normal',
               use_bias=False)(se)
    se = Dense(filters,
               activation='sigmoid',
               kernel_initializer='he_normal',
               use_bias=False)(se)
    se = multiply([input, se])
    return se


if __name__ == "__main__":
    from time import time

    model = generate_model_2()

    train_model(model,
                DATASET_INDEX,
                dataset_prefix='lp3_',
                epochs=100,
                batch_size=128)

    evaluate_model(model, DATASET_INDEX, dataset_prefix='lp3_', batch_size=128)
                         (cfmatrix.sum(axis=1) / sum(cfmatrix.sum(axis=1))))
    weightedf = metrics.f1_score(y_test, y_pred, average='weighted')

    print()
    print("Binary F-Score : ", microf)
    print("Final F-Score : ", averagef)
    print("Weighted F-Score : ", weightedf)

    print("Mahis F-Score : ", averagef_mahi)
    print("Mahis W F-Score : ", weightedf_mahi)
    return averagef


if __name__ == "__main__":
    model = generate_model_2()
    model.compile('adam',
                  'categorical_crossentropy',
                  metrics=['accuracy', f1_score])

    train_model(model,
                DATASET_INDEX,
                dataset_prefix='opportunity_new',
                epochs=1000,
                batch_size=128,
                monitor='val_f1_score',
                optimization_mode='max',
                compile_model=False)

    #evaluate_model(model, DATASET_INDEX, dataset_prefix='opportunity', batch_size=128)
    #predict_model(model, DATASET_INDEX, dataset_prefix='opportunity_weights_attention_9208_512_lstm_128', batch_size=512)
Esempio n. 5
0
    '''
    filters = input._keras_shape[-1]  # channel_axis = -1 for TF

    se = GlobalAveragePooling1D()(input)
    se = Reshape((1, filters))(se)
    se = Dense(filters // 16,
               activation='relu',
               kernel_initializer='he_normal',
               use_bias=False)(se)
    se = Dense(filters,
               activation='sigmoid',
               kernel_initializer='he_normal',
               use_bias=False)(se)
    se = multiply([input, se])
    return se


if __name__ == "__main__":
    model = generate_model_2()

    train_model(model,
                DATASET_INDEX,
                dataset_prefix='arabic_voice_',
                epochs=1000,
                batch_size=128)

    evaluate_model(model,
                   DATASET_INDEX,
                   dataset_prefix='arabic_voice_',
                   batch_size=128)
Esempio n. 6
0
    # add load model code here to fine-tune

    return model


def squeeze_excite_block(input):
    ''' Create a squeeze-excite block
    Args:
        input: input tensor
        filters: number of output filters
        k: width factor

    Returns: a keras tensor
    '''
    filters = input._keras_shape[-1] # channel_axis = -1 for TF

    se = GlobalAveragePooling1D()(input)
    se = Reshape((1, filters))(se)
    se = Dense(filters // 16,  activation='relu', kernel_initializer='he_normal', use_bias=False)(se)
    se = Dense(filters, activation='sigmoid', kernel_initializer='he_normal', use_bias=False)(se)
    se = multiply([input, se])
    return se


if __name__ == "__main__":
    model = generate_model_2()

    train_model(model, DATASET_INDEX, dataset_prefix='activity_attention', epochs=1000, batch_size=128)

    evaluate_model(model, DATASET_INDEX, dataset_prefix='activity_attention', batch_size=128)
Esempio n. 7
0
    '''
    filters = input._keras_shape[-1]  # channel_axis = -1 for TF

    se = GlobalAveragePooling1D()(input)
    se = Reshape((1, filters))(se)
    se = Dense(filters // 16,
               activation='relu',
               kernel_initializer='he_normal',
               use_bias=False)(se)
    se = Dense(filters,
               activation='sigmoid',
               kernel_initializer='he_normal',
               use_bias=False)(se)
    se = multiply([input, se])
    return se


if __name__ == "__main__":
    model = generate_model()

    train_model(model,
                DATASET_INDEX,
                dataset_prefix='daily_sport_no_attention',
                epochs=500,
                batch_size=128)

    evaluate_model(model,
                   DATASET_INDEX,
                   dataset_prefix='daily_sport_no_attention',
                   batch_size=128)
    '''
    filters = input._keras_shape[-1]  # channel_axis = -1 for TF

    se = GlobalAveragePooling1D()(input)
    se = Reshape((1, filters))(se)
    se = Dense(filters // 16,
               activation='relu',
               kernel_initializer='he_normal',
               use_bias=False)(se)
    se = Dense(filters,
               activation='sigmoid',
               kernel_initializer='he_normal',
               use_bias=False)(se)
    se = multiply([input, se])
    return se


if __name__ == "__main__":
    model = generate_model_2()

    train_model(model,
                DATASET_INDEX,
                dataset_prefix='movement_aal',
                epochs=1000,
                batch_size=128)

    evaluate_model(model,
                   DATASET_INDEX,
                   dataset_prefix='movement_aal',
                   batch_size=128)
    # add load model code here to fine-tune

    return model

def squeeze_excite_block(input):
    ''' Create a squeeze-excite block
    Args:
        input: input tensor
        filters: number of output filters
        k: width factor

    Returns: a keras tensor
    '''
    filters = input._keras_shape[-1] # channel_axis = -1 for TF

    se = GlobalAveragePooling1D()(input)
    se = Reshape((1, filters))(se)
    se = Dense(filters // 16,  activation='relu', kernel_initializer='he_normal', use_bias=False)(se)
    se = Dense(filters, activation='sigmoid', kernel_initializer='he_normal', use_bias=False)(se)
    se = multiply([input, se])
    return se


if __name__ == "__main__":
    model = generate_model_2()

    train_model(model, DATASET_INDEX, dataset_prefix='japanese_vowels', epochs=600, batch_size=128)

    evaluate_model(model, DATASET_INDEX, dataset_prefix='japanese_vowels', batch_size=128)
Esempio n. 10
0
    '''
    filters = input._keras_shape[-1]  # channel_axis = -1 for TF

    se = GlobalAveragePooling1D()(input)
    se = Reshape((1, filters))(se)
    se = Dense(filters // 16,
               activation='relu',
               kernel_initializer='he_normal',
               use_bias=False)(se)
    se = Dense(filters,
               activation='sigmoid',
               kernel_initializer='he_normal',
               use_bias=False)(se)
    se = multiply([input, se])
    return se


if __name__ == "__main__":
    model = generate_model()

    train_model(model,
                DATASET_INDEX,
                dataset_prefix='gesture_phase',
                epochs=1000,
                batch_size=128)

    evaluate_model(model,
                   DATASET_INDEX,
                   dataset_prefix='gesture_phase',
                   batch_size=128)