예제 #1
0
        # Compile the model with an Adam optimizar and a learning rate of 0.02
        model.compile(loss='binary_crossentropy', optimizer=RMSprop(lr=0.0001))
        checkpoint = ModelCheckpoint('keras_models/weights.hdf5',
                                     monitor='val_loss',
                                     verbose=0,
                                     save_best_only=True,
                                     mode='auto')

        # Train the model
        history = model.fit(x_train,
                            y_train,
                            validation_data=(x_test, y_test),
                            batch_size=4,
                            epochs=100,
                            callbacks=[checkpoint])
        model.load_weights('keras_models/weights.hdf5')
        save_model(model)

    else:
        model = load_model()

    # Make predictions
    predictions = model.predict(x_test)
    predictions = predictions.round()

    # Load prediction data and history to plot interesting graphs
    graphics = Graphics()

    if option == "2":
        graphics.load_data(predictions, y_test)