ParallelResilientBackpropagationLearning Class |
Namespace: Accord.Neuro.Learning
The ParallelResilientBackpropagationLearning type exposes the following members.
Name | Description | |
---|---|---|
ParallelResilientBackpropagationLearning |
Initializes a new instance of the ParallelResilientBackpropagationLearning class.
|
Name | Description | |
---|---|---|
DecreaseFactor |
Gets the decrease parameter, also
referred as eta minus. Default is 0.5.
| |
IncreaseFactor |
Gets the increase parameter, also
referred as eta plus. Default is 1.2.
| |
UpdateLowerBound |
Gets or sets the minimum possible update step,
also referred as delta max. Default is 1e-6.
| |
UpdateUpperBound |
Gets or sets the maximum possible update step,
also referred as delta min. Default is 50.
|
Name | Description | |
---|---|---|
ComputeError |
Compute network error for a given data set.
| |
Dispose |
Performs application-defined tasks associated with freeing,
releasing, or resetting unmanaged resources.
| |
Dispose(Boolean) |
Releases unmanaged and - optionally - managed resources
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize |
Releases unmanaged resources and performs other cleanup operations before
the ParallelResilientBackpropagationLearning is reclaimed by garbage
collection.
(Overrides ObjectFinalize.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Reset |
Resets the current update steps using the given learning rate.
| |
Run |
Runs learning iteration.
| |
RunEpoch |
Runs learning epoch.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(Type) | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) | |
ToT | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) |
This class implements the resilient backpropagation (RProp) learning algorithm. The RProp learning algorithm is one of the fastest learning algorithms for feed-forward learning networks which use only first-order information.
Sample usage (training network to calculate XOR function):
// initialize input and output values double[][] input = { new double[] {0, 0}, new double[] {0, 1}, new double[] {1, 0}, new double[] {1, 1} }; double[][] output = { new double[] {0}, new double[] {1}, new double[] {1}, new double[] {0} }; // create neural network ActivationNetwork network = new ActivationNetwork( SigmoidFunction(2), 2, // two inputs in the network 2, // two neurons in the first layer 1 ); // one neuron in the second layer // create teacher var teacher = new ResilientBackpropagationLearning(network); // loop while (!needToStop) { // run epoch of learning procedure double error = teacher.RunEpoch( input, output ); // check error value to see if we need to stop // ... }
The following example shows how to use Rprop to solve a multi-class classification problem.
// Suppose we would like to teach a network to recognize // the following input vectors into 3 possible classes: // double[][] inputs = { new double[] { 0, 1, 1, 0 }, // 0 new double[] { 0, 1, 0, 0 }, // 0 new double[] { 0, 0, 1, 0 }, // 0 new double[] { 0, 1, 1, 0 }, // 0 new double[] { 0, 1, 0, 0 }, // 0 new double[] { 1, 0, 0, 0 }, // 1 new double[] { 1, 0, 0, 0 }, // 1 new double[] { 1, 0, 0, 1 }, // 1 new double[] { 0, 0, 0, 1 }, // 1 new double[] { 0, 0, 0, 1 }, // 1 new double[] { 1, 1, 1, 1 }, // 2 new double[] { 1, 0, 1, 1 }, // 2 new double[] { 1, 1, 0, 1 }, // 2 new double[] { 0, 1, 1, 1 }, // 2 new double[] { 1, 1, 1, 1 }, // 2 }; int[] classes = { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, }; // First we have to convert this problem into a way that the neural // network can handle. The first step is to expand the classes into // indicator vectors, where a 1 into a position signifies that this // position indicates the class the sample belongs to. // double[][] outputs = Measures.Expand(classes, -1, +1); // Create an activation function for the net var function = new BipolarSigmoidFunction(); // Create an activation network with the function and // 4 inputs, 5 hidden neurons and 3 possible outputs: var network = new ActivationNetwork(function, 4, 5, 3); // Randomly initialize the network new NguyenWidrow(network).Randomize(); // Teach the network using parallel Rprop: var teacher = new ParallelResilientBackpropagationLearning(network); double error = 1.0; while (error > 1e-5) error = teacher.RunEpoch(inputs, outputs); // Checks if the network has learned for (int i = 0; i < inputs.Length; i++) { double[] answer = network.Compute(inputs[i]); int expected = classes[i]; int actual; answer.Max(out actual); // actual should be equal to expected }