Click or drag to resize
Accord.NET (logo)

HiddenResilientGradientLearningT Class

Resilient Gradient Learning.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.Models.Fields.LearningHiddenResilientGradientLearningT

Namespace:  Accord.Statistics.Models.Fields.Learning
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.5.0
Syntax
public class HiddenResilientGradientLearning<T> : ISupervisedLearning<HiddenConditionalRandomField<T>, T[], int>, 
	IHiddenConditionalRandomFieldLearning<T>, IConvergenceLearning, IDisposable
Request Example View Source

Type Parameters

T
The type of the observations being modeled.

The HiddenResilientGradientLearningT type exposes the following members.

Constructors
  NameDescription
Public methodHiddenResilientGradientLearningT
Initializes a new instance of the HiddenResilientGradientLearningT class.
Top
Properties
  NameDescription
Public propertyDecreaseFactor
Gets the decrease parameter, also referred as eta minus. Default is 0.5.
Public propertyIncreaseFactor
Gets the increase parameter, also referred as eta plus. Default is 1.2.
Public propertyIterations
Gets or sets the maximum number of iterations performed by the learning algorithm.
Public propertyModel
Gets or sets the model being trained.
Public propertyRegularization
Gets or sets the amount of the parameter weights which should be included in the objective function. Default is 0 (do not include regularization).
Public propertyStochastic
Public propertyToken
Gets or sets a cancellation token that can be used to stop the learning algorithm while it is running.
Public propertyTolerance
Gets or sets the maximum change in the average log-likelihood after an iteration of the algorithm used to detect convergence.
Public propertyUpdateLowerBound
Gets or sets the minimum possible update step, also referred as delta max. Default is 1e-6.
Public propertyUpdateUpperBound
Gets or sets the maximum possible update step, also referred as delta min. Default is 50.
Top
Methods
  NameDescription
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Protected methodDispose(Boolean)
Releases unmanaged and - optionally - managed resources
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Releases unmanaged resources and performs other cleanup operations before the HiddenResilientGradientLearningT is reclaimed by garbage collection.
(Overrides ObjectFinalize.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodLearn
Learns a model that can map the given inputs to the given outputs.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnProgressChanged
Raises the [E:ProgressChanged] event.
Public methodReset
Resets the current update steps using the given learning rate.
Public methodRun(T, Int32)
Runs one iteration of the learning algorithm with the specified input training observation and corresponding output label.
Public methodRun(T, Int32) Obsolete.
Runs one iteration of the learning algorithm with the specified input training observation and corresponding output label.
Public methodRunEpoch
Runs the learning algorithm with the specified input training observations and corresponding output labels.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Events
  NameDescription
Public eventProgressChanged
Occurs when the current learning progress has changed.
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodToTOverloaded.
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.)
Public Extension MethodToTOverloaded.
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 Matrix.)
Top
Examples
// Suppose we would like to learn how to classify the
// following set of sequences among three class labels: 

int[][] inputSequences =
{
    // First class of sequences: starts and
    // ends with zeros, ones in the middle:
    new[] { 0, 1, 1, 1, 0 },        
    new[] { 0, 0, 1, 1, 0, 0 },     
    new[] { 0, 1, 1, 1, 1, 0 },     

    // Second class of sequences: starts with
    // twos and switches to ones until the end.
    new[] { 2, 2, 2, 2, 1, 1, 1, 1, 1 },
    new[] { 2, 2, 1, 2, 1, 1, 1, 1, 1 },
    new[] { 2, 2, 2, 2, 2, 1, 1, 1, 1 },

    // Third class of sequences: can start
    // with any symbols, but ends with three.
    new[] { 0, 0, 1, 1, 3, 3, 3, 3 },
    new[] { 0, 0, 0, 3, 3, 3, 3 },
    new[] { 1, 0, 1, 2, 2, 2, 3, 3 },
    new[] { 1, 1, 2, 3, 3, 3, 3 },
    new[] { 0, 0, 1, 1, 3, 3, 3, 3 },
    new[] { 2, 2, 0, 3, 3, 3, 3 },
    new[] { 1, 0, 1, 2, 3, 3, 3, 3 },
    new[] { 1, 1, 2, 3, 3, 3, 3 },
};

// Now consider their respective class labels
int[] outputLabels =
{
    /* Sequences  1-3 are from class 0: */ 0, 0, 0,
    /* Sequences  4-6 are from class 1: */ 1, 1, 1,
    /* Sequences 7-14 are from class 2: */ 2, 2, 2, 2, 2, 2, 2, 2
};


// Create the Hidden Conditional Random Field using a set of discrete features
var function = new MarkovDiscreteFunction(states: 3, symbols: 4, outputClasses: 3);
var classifier = new HiddenConditionalRandomField<int>(function);

// Create a learning algorithm
var teacher = new HiddenResilientGradientLearning<int>(classifier)
{
    Iterations = 50
};

// Run the algorithm and learn the models
teacher.Run(inputSequences, outputLabels);


// After training has finished, we can check the 
// output classification label for some sequences. 

int y1 = classifier.Compute(new[] { 0, 1, 1, 1, 0 });    // output is y1 = 0
int y2 = classifier.Compute(new[] { 0, 0, 1, 1, 0, 0 }); // output is y1 = 0

int y3 = classifier.Compute(new[] { 2, 2, 2, 2, 1, 1 }); // output is y2 = 1
int y4 = classifier.Compute(new[] { 2, 2, 1, 1 });       // output is y2 = 1

int y5 = classifier.Compute(new[] { 0, 0, 1, 3, 3, 3 }); // output is y3 = 2
int y6 = classifier.Compute(new[] { 2, 0, 2, 2, 3, 3 }); // output is y3 = 2
See Also