示例#1
0
    def train(self):
        if self.find_lr == True:
            # Navigate to output folder in parent directory
            go_up_three_dirs()        

            # Plot learning rate finder plot
            self.lr_finder.plot_loss(
                "output/lr_finder_plot_A1.png")
                
        else:
            # Plot training loss accuracy and learning rate change
            # Navigate to output folder in parent directory
            go_up_three_dirs()

            plot_train_loss_acc_lr(
                self.history,
                int(self.epochs/2),
                self.schedule,
                self.schedule_type,
                "A1",
                "output/train_loss_acc_A1_xception.png",
                "output/lr_A1_xception.png")

            # Get the training accuracy
            training_accuracy = self.history.history['val_acc'][-1]
            return training_accuracy
示例#2
0
    def train(self):
        if self.find_lr == True:
            # Navigate to output folder in parent directory
            go_up_three_dirs()        

            print("[INFO] Creating learning rate finder plot...")
            # Plot learning rate finder plot
            self.lr_finder.plot_loss(
                "output/lr_finder_plot_B2.png")
        else:
            # Plot training loss accuracy and learning rate change
            # Navigate to output folder in parent directory
            go_up_three_dirs()

            plot_train_loss_acc_lr(
                self.history,
                self.epochs,
                self.schedule,
                self.schedule_type,
                "B2",
                "output/train_loss_acc_B2_cnn.png",
                "output/lr_B2_cnn.png")

            # Get the training accuracy
            training_accuracy = self.history.history['val_acc'][-1]
            return training_accuracy
示例#3
0
    def test(self):
        # Go back to image folder
        os.chdir("data/dataset_test_AMLS_19-20/celeba_test")

        # Split ImageDataGenerator object for the test set into separate X and y test sets
        X_test, y_test = get_X_y_test_sets(self.test_gen)

        # Navigate to output folder in parent directory
        go_up_three_dirs()

        # Plot top losses
        plot_top_losses(self.model, X_test, y_test, "output/plot_top_losses_A1_mlp.png")

        # Get the test accuracy
        test_accuracy = self.model.evaluate(X_test, y_test)[-1]
        return test_accuracy
示例#4
0
    def test(self):
        # Go back to image folder
        os.chdir("data/dataset_test_AMLS_19-20/cartoon_set_test")

        # Split ImageDataGenerator object for the test set into separate X and y test sets
        X_test, y_test = get_X_y_test_sets(self.test_gen)

        # Navigate to output folder in parent directory
        go_up_three_dirs()

        # Plot top losses
        plot_top_losses(self.model, X_test, y_test, "output/plot_top_losses_B2_xception.png")

        # Plot GradCam
        plot_grad_cam(self.model, X_test, y_test, 3, "block14_sepconv2", "output/plot_top_5_gradcam_B2_xception.png")

        # Get the test accuracy
        test_accuracy = self.model.evaluate(X_test, y_test)[-1]
        return test_accuracy