Esempio n. 1
0
    def continue_finetuning(self, epochs, binary_output=False):
        """
        Continue finetuning. This will only run if the finetuning has already run.

        @param epochs: Number of epochs to run the finetuning.
        @param binary_output: If the DBN must output binary values.
        """

        self.weight_matrices = load_dbn_weights()
        self.load_finetuning_output_txt()
        self.print_output('Fine Tuning (continued)')
        timer = time()
        fine_tuning = FineTuning(self.weight_matrices,
                                 self.batches,
                                 self.print_output,
                                 binary_output=binary_output)

        fine_tuning.run_finetuning(epochs)

        fine_tuning_error_train = fine_tuning.train_error
        fine_tuning_error_test = fine_tuning.test_error

        self.print_output('Time ' + str(time() - timer))
        save_dbn(fine_tuning.weight_matrices_added_biases,
                 fine_tuning_error_train, fine_tuning_error_test)
        self.output_dbn_errors(fine_tuning_error_train, fine_tuning_error_test)
        self.save_output()
Esempio n. 2
0
    def run_finetuning(self, load_from_serialization=False):
        """
        Run the finetuning of the DBN. This will only run if the pretraining has been run.

        @param load_from_serialization: If the weight matrices are not loaded into memory, this should be True.
        """
        try:
            if load_from_serialization:
                self.weight_matrices, self.hidden_biases, self.visible_biases = load_rbm_weights(
                )
        except IOError:
            print 'Please run pretraining before executing finetuning.'
            return

        self.print_output('Fine Tuning')
        timer = time()

        fine_tuning = FineTuning(self.weight_matrices,
                                 self.batches,
                                 self.print_output,
                                 self.hidden_biases,
                                 self.visible_biases,
                                 binary_output=self.binary_output)
        fine_tuning.run_finetuning(self.max_epochs)

        fine_tuning_error_train = fine_tuning.train_error
        fine_tuning_error_test = fine_tuning.test_error

        self.print_output('Time ' + str(time() - timer))
        save_dbn(fine_tuning.weight_matrices_added_biases,
                 fine_tuning_error_train, fine_tuning_error_test)
        self.output_dbn_errors(fine_tuning_error_train, fine_tuning_error_test)
        self.save_output()
    def run_finetuning(self, load_from_serialization = False):
        """
        Run the finetuning of the DBN. This will only run if the pretraining has been run.

        @param load_from_serialization: If the weight matrices are not loaded into memory, this should be True.
        """
        try:
            if load_from_serialization:
                self.weight_matrices,self.hidden_biases,self.visible_biases = load_rbm_weights()
        except IOError:
            print 'Please run pretraining before executing finetuning.'
            return

        self.print_output('Fine Tuning')
        timer = time()

        fine_tuning = FineTuning(self.weight_matrices, self.batches,self.print_output,self.increment_progress,
                                 self.hidden_biases,self.visible_biases,binary_output = self.binary_output)
        fine_tuning.run_finetuning(self.max_epochs)
        
        fine_tuning_error_train = fine_tuning.train_error
        fine_tuning_error_test = fine_tuning.test_error
        if self.plot:
            self.plot_finetuning_error(fine_tuning_error_train, fine_tuning_error_test)

        self.print_output('Time '+str(time()-timer))
        save_dbn(fine_tuning.weight_matrices_added_biases,fine_tuning_error_train,fine_tuning_error_test)
        self.output_dbn_errors(fine_tuning_error_train,fine_tuning_error_test)
        self.save_output()
    def continue_finetuning(self,epochs,binary_output = False):
        """
        Continue finetuning. This will only run if the finetuning has already run.

        @param epochs: Number of epochs to run the finetuning.
        @param binary_output: If the DBN must output binary values.
        """

        self.weight_matrices = load_dbn_weights()
        self.load_finetuning_output_txt()
        self.print_output('Fine Tuning (continued)')
        timer = time()
        fine_tuning = FineTuning(self.weight_matrices, self.batches,self.print_output,self.increment_progress,binary_output = binary_output)
        
        fine_tuning.run_finetuning(epochs)
        
        fine_tuning_error_train = fine_tuning.train_error
        fine_tuning_error_test = fine_tuning.test_error
        
        self.print_output('Time '+str(time()-timer))
        save_dbn(fine_tuning.weight_matrices_added_biases,fine_tuning_error_train,fine_tuning_error_test)
        self.output_dbn_errors(fine_tuning_error_train,fine_tuning_error_test)
        self.save_output()