Logo Search packages:      
Sourcecode: python-biopython version File versions

def Bio::NeuralNetwork::BackPropagation::Network::BasicNetwork::train (   self,
  training_examples,
  validation_examples,
  stopping_criteria,
  learning_rate,
  momentum 
)

Train the neural network to recognize particular examples.

Arguments:

o training_examples -- A list of TrainingExample classes that will
be used to train the network.

o validation_examples -- A list of TrainingExample classes that
are used to validate the network as it is trained. These examples
are not used to train so the provide an independent method of
checking how the training is doing. Normally, when the error
from these examples starts to rise, then it's time to stop
training.

o stopping_criteria -- A function, that when passed the number of
iterations, the training error, and the validation error, will
determine when to stop learning.

o learning_rate -- The learning rate of the neural network.

o momentum -- The momentum of the NN, which describes how much
of the prevoious weight change to use.

Definition at line 35 of file Network.py.

                                                         :
        """Train the neural network to recognize particular examples.

        Arguments:

        o training_examples -- A list of TrainingExample classes that will
        be used to train the network.

        o validation_examples -- A list of TrainingExample classes that
        are used to validate the network as it is trained. These examples
        are not used to train so the provide an independent method of
        checking how the training is doing. Normally, when the error
        from these examples starts to rise, then it's time to stop
        training.

        o stopping_criteria -- A function, that when passed the number of
        iterations, the training error, and the validation error, will
        determine when to stop learning.

        o learning_rate -- The learning rate of the neural network.

        o momentum -- The momentum of the NN, which describes how much
        of the prevoious weight change to use.
        """
        num_iterations = 0
        while 1:
            num_iterations += 1
            training_error = 0.0
            for example in training_examples:
                # update the predicted values for all of the nodes
                # based on the current weights and the inputs
                # This propogates over the entire network from the input.
                self._input.update(example.inputs)

                # calculate the error via back propogation
                self._input.backpropagate(example.outputs,
                                          learning_rate, momentum)
            
                # get the errors in our predictions
                for node in range(len(example.outputs)):
                    training_error += \
                             self._output.get_error(example.outputs[node],
                                                    node + 1)

            # get the current testing error for the validation examples
            validation_error = 0.0
            for example in validation_examples:
                predictions = self.predict(example.inputs)

                for prediction_num in range(len(predictions)):
                    real_value = example.outputs[prediction_num]
                    predicted_value = predictions[prediction_num]
                    validation_error += \
                            0.5 * math.pow((real_value - predicted_value), 2)

            # see if we have gone far enough to stop
            if stopping_criteria(num_iterations, training_error,
                                 validation_error):
                break

    def predict(self, inputs):


Generated by  Doxygen 1.6.0   Back to index