Esempio n. 1
0
experiment_name = "experiment_{}_batch_size_{}_bn_{}_dr{}_nl_{}_ml_{}".format(
    experiment_prefix, batch_size, batch_norm, dropout_rate, n_layers, max_len)
saved_models_filepath, logs_filepath = build_experiment_folder(
    experiment_name, logs_path)
filepath = "{}/best_validation_{}".format(saved_models_filepath,
                                          experiment_name)
checkpoint = ModelCheckpoint(filepath,
                             monitor='val_acc',
                             verbose=1,
                             save_best_only=True,
                             mode='max')

from multimodaldata import get_data
train_set_audio, valid_set_audio, test_set_audio, train_set_text, valid_set_text, test_set_text, \
train_set_visual, valid_set_visual, test_set_visual, \
y_train, y_valid, y_test = get_data(max_len_audio=20, max_len_text=15, max_len_visual=20)

filepath = "{}/best_validation_{}_".format(saved_models_filepath,
                                           experiment_name)
weights = "{}_weights{}.h5"
# pdb.set_trace()
k = 3
m = 2
# AUDIO
model1_in = Input(name="Audio_Covarep",
                  shape=(train_set_audio.shape[1], train_set_audio.shape[2]))
model1_cnn = Conv1D(filters=64, kernel_size=k, activation='relu')(model1_in)
model1_mp = MaxPooling1D(m)(model1_cnn)
model1_fl = Flatten()(model1_mp)
model1_dense = Dense(128, activation="relu",
                     W_regularizer=l2(0.0001))(model1_fl)
Esempio n. 2
0
                                           experiment_name)
weights = "{}late_fusion_weights{}.h5"
# pdb.set_trace()
k = 3
m = 2

for max_len in [15, 20, 25, 30]:
    for dropout_rate in [0.0, 0.1, 0.2]:
        for n_layers in [1, 2, 3]:

            logging.info("New experiment")
            logging.info("*" * 30)

            train_set_audio, valid_set_audio, test_set_audio, train_set_text, valid_set_text, test_set_text, \
            train_set_visual, valid_set_visual, test_set_visual, \
            y_train, y_valid, y_test = get_data(max_len_audio=max_len, max_len_text=max_len, max_len_visual=max_len)

            # AUDIO
            model1_in = Input(name="Audio_Covarep",
                              shape=(train_set_audio.shape[1],
                                     train_set_audio.shape[2]))
            model1_cnn = Conv1D(filters=64, kernel_size=k,
                                activation='relu')(model1_in)
            model1_mp = MaxPooling1D(m)(model1_cnn)
            model1_fl = Flatten()(model1_mp)
            model1_dropout = Dropout(dropout_rate)(model1_fl)
            model1_dense = Dense(128,
                                 activation="relu",
                                 W_regularizer=l2(0.0001))(model1_dropout)
            for i in range(2, n_layers + 1):
                model1_dropout = Dropout(dropout_rate)(model1_dense)