Пример #1
0
                            train_generator=train_generator,
                            val_generator=val_generator,
                            callbacks=callbacks)

#%%############################################################################
# Evaluate the model
###############################################################################
# Load unstandardized test data
X_test_data, y_test_data = datatools.load_data(path_to_dataset=path_to_dataset,
                                               data_list=test_list,
                                               input_shape=data_shape,
                                               standardization_mode=None,
                                               border=border)
if evaluate == True:
    test_loss = cnn.evaluate_model(X_test=np.expand_dims(X_test_data, axis=4),
                                   y_test=np.expand_dims(y_test_data, axis=4),
                                   batch_size=batch_size)
    print(test_loss)

#%%############################################################################
# Save the model
###############################################################################

cnn.save_model_json(model_export_path, 'model_json')
cnn.save_model_weights(model_export_path, 'model_weights')
cnn.save_model_single_file(model_export_path, 'model_single')

#%%############################################################################
# Load the model
###############################################################################
Пример #2
0
with open(hist_pd_csv_file, mode='w') as f:
    history_df.to_csv(f)

###############################################################################
# Evaluate the model
###############################################################################
# Load unstandardized test data
X_test_data, y_test_data = datatools.load_data(path_to_dataset=path_to_dataset,
                                               data_list=test_files,
                                               input_shape=data_shape,
                                               standardization_mode=None,
                                               border=border)
if evaluate == True:
    # Evaluate the model on the test-data
    test_loss = cnn.evaluate_model(X_test=X_test_data,
                                   y_test=y_test_data,
                                   batch_size=batch_size)
    print(test_loss)

    # Export the value of the test-loss
    test_loss_export_path = os.path.join(model_export_path, 'test_loss.txt')
    with open(test_loss_export_path, 'w') as file:
        for l in range(len(test_loss)):
            file.write(str(test_loss[l]) + '\n')

###############################################################################
# Save the model
###############################################################################
cnn.save_model_json(model_export_path, 'model_json')
cnn.save_model_weights(model_export_path, 'model_weights')
cnn.save_model_single_file(model_export_path, 'model_single')