Esempio n. 1
0
                        epochs=epochs,
                        verbose=verbose)  # starts training

with open(path_to_dir + 'log.txt', 'a+') as f:
    f.write(file_name + '\n')
    f.write(directory_name + '\n\n')

# outputs:
# ============================================================================================================================
# SAVE

# model.save(path_to_dir + 'model.h5', overwrite=True) #Save model #TODO: not working nor checkpoint save model
# model.save_weights(path_to_dir +"model_weights.h5", overwrite=True)
# plot_model(model, to_file=path_to_dir + 'model.png') # Save plot of model
np.save(path_to_dir + 'history_dict.npy', history.history)  #Save history
plot_outputs.learning_curve(history.history, path_to_dir)  #'loss' 'both'
accuracy = model.evaluate(
    Xtest_encoded, Ytest_encoded,
    verbose=verbose)  # TODO:change to test set for final model.
with open(path_to_dir + 'log.txt', 'a+') as f:
    f.write(file_name + str(accuracy) + '\n')
Ypredict = model.predict(
    Xtest_encoded, batch_size=batch_size,
    verbose=verbose)  # TODO:change to test set for final model.
Ypredict_encoded = np_utils.to_categorical(Ypredict.argmax(axis=-1))
Ypredict_integer = Ypredict.argmax(axis=-1)
np.save(path_to_dir + 'Ypredict_integer', Ypredict_integer)
clas_rep = classification_report(
    Ytest_encoded, Ypredict_encoded,
    target_names=categories)  # TODO:change to test set for final model.
df_clas_rep, df_clas_rep_latex = plot_outputs.classification_report_df(
Esempio n. 2
0
    'val_loss': [
        1.0920380201935769, 1.0093031644821167, 1.0757258840401966,
        1.2028360558549562, 1.4188584667444228, 1.6316908218463262,
        1.766864692568779, 2.0251855607827505, 2.060387311379115,
        2.1677825838327407
    ],
    'loss': [
        1.3953080095847448, 0.9260162450869878, 0.6677782966693242,
        0.45178923646608987, 0.3067782683918873, 0.21935892856369416,
        0.16770731837799152, 0.1326430987815062, 0.10937795276443163,
        0.09297534093881647
    ]
}
input_dir = '/Users/danielmlow/Dropbox/cnn/thesis/manuscript/tables_and_figures/'
importlib.reload(plot_outputs)
plot_outputs.learning_curve(d, input_dir)
'''
:param history:  model.fit(X, Y, validation_split=0.33, epochs=150, batch_size=10, verbose=0)
:return: plot
'''
# list all data in history
plt.clf()
history = {
    'acc': [
        0.608408203125, 0.732587890625, 0.80271484375, 0.863232421875,
        0.90556640625, 0.931591796875, 0.9465787760416666, 0.9570865885416666,
        0.9646321614583333, 0.96919921875
    ],
    'val_acc': [
        0.6915755208333333, 0.7134635416666667, 0.7146744791666667,
        0.7097135416666667, 0.7052083333333333, 0.6964973958333334,