Exemplo n.º 1
0
                     workers=ngpu,
                     callbacks=callback_list,
                     verbose=1)

################ Test with best trained models
pmodel.load_weights(output_best_model)
# Compile model (required to make predictions)
pmodel.compile(loss='binary_crossentropy',
               optimizer='rmsprop',
               metrics=['accuracy', ef.fbeta_score])

flog.write('best model monitored')

ef.evaluate(pmodel,
            test_generator1,
            flog=flog,
            name=file_test_label1,
            output_file=file_test_label1.replace('.mat', '_sepcnn_output.txt'))
ef.evaluate(pmodel,
            test_generator2,
            flog=flog,
            name=file_test_label2,
            output_file=file_test_label2.replace('.mat', '_sepcnn_output.txt'))
ef.evaluate(pmodel,
            test_generator3,
            flog=flog,
            name=file_test_label3,
            output_file=file_test_label3.replace('.mat', '_sepcnn_output.txt'))

pmodel.save(output_model_cnn)
pmodel.save_weights(output_best_model)
Exemplo n.º 2
0
################## Testing
parallel_model.load_weights(output_best_model)

parallel_model.compile(loss='binary_crossentropy', optimizer='rmsprop',
                       metrics=['accuracy', ef.fbeta_score])

print('best model monitored')
flog.write('best model monitored')

parallel_model.save(output_model_cnn)
parallel_model.save_weights(output_best_model)

model.save(output_model_cnn.replace('.h5', '_1gpu.h5'))
model.save_weights(output_best_model.replace('.h5', '_1gpu.h5'))

ef.evaluate(parallel_model, test_generator)

#########
flog.close()











Exemplo n.º 3
0
callback_list = [checkpoint, roc, early_stopping]

trained_history = pmodel.fit_generator(generator=train_generator,
                                       epochs=epoch,
                                       shuffle=True,
                                       validation_data=val_generator,
                                       use_multiprocessing=False,
                                       workers=1,
                                       callbacks=callback_list,
                                       verbose=1)

############## Testing
pmodel.load_weights(output_best_model)
pmodel.compile(loss='binary_crossentropy',
               optimizer='rmsprop',
               metrics=['accuracy', ef.fbeta_score])

print('best model monitored')
flog.write('best model monitored')

ef.evaluate(pmodel, test_generator, flog=flog)

pmodel.save(output_model)
pmodel.save_weights(output_best_model)

model.save(output_model.replace('.h5', '_1gpu.h5'))
model.save_weights(output_best_model.replace('.h5', '_1gpu.h5'))

#########
flog.close()