RestrictedBoltzmannMachine Class |
Namespace: Accord.Neuro.Networks
The RestrictedBoltzmannMachine type exposes the following members.
Name | Description | |
---|---|---|
RestrictedBoltzmannMachine(Int32, Int32) |
Creates a new RestrictedBoltzmannMachine.
| |
RestrictedBoltzmannMachine(StochasticLayer, StochasticLayer) |
Creates a new RestrictedBoltzmannMachine.
| |
RestrictedBoltzmannMachine(IStochasticFunction, Int32, Int32) |
Creates a new RestrictedBoltzmannMachine.
|
Name | Description | |
---|---|---|
Hidden |
Gets the hidden layer of the machine.
| |
InputsCount |
Network's inputs count.
(Inherited from Network.) | |
Layers |
Network's layers.
(Inherited from Network.) | |
Output |
Network's output vector.
(Inherited from Network.) | |
Visible |
Gets the visible layer of the machine.
|
Name | Description | |
---|---|---|
Compute |
Compute output vector of the network.
(Overrides NetworkCompute(Double).) | |
CreateGaussianBernoulli |
Constructs a Gaussian-Bernoulli network with
visible Gaussian units and hidden Bernoulli units.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GenerateInput |
Samples an input vector from the network
given an output vector.
| |
GenerateOutput |
Samples an output vector from the network
given an input vector.
| |
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.) | |
Randomize |
Randomize layers of the network.
(Inherited from Network.) | |
Reconstruct |
Reconstructs a input vector for a given output.
| |
Save(Stream) |
Save network to specified file.
(Inherited from Network.) | |
Save(String) |
Save network to specified file.
(Inherited from Network.) | |
SetActivationFunction |
Set new activation function for all neurons of the network.
(Inherited from ActivationNetwork.) | |
ToActivationNetwork(Int32) |
Creates a new ActivationNetwork from this instance.
| |
ToActivationNetwork(IActivationFunction, Int32) |
Creates a new ActivationNetwork from this instance.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
UpdateVisibleWeights |
Updates the weights of the visible layer by copying
the reverse of the weights in the hidden layer.
|
Name | Description | |
---|---|---|
inputsCount |
Network's inputs count.
(Inherited from Network.) | |
layers |
Network's layers.
(Inherited from Network.) | |
layersCount |
Network's layers count.
(Inherited from Network.) | |
output |
Network's output vector.
(Inherited from Network.) |
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.) |
// Create some sample inputs and outputs. Note that the // first four vectors belong to one class, and the other // four belong to another (you should see that the 1s // accumulate on the beginning for the first four vectors // and on the end for the second four). double[][] inputs = { new double[] { 1,1,1, 0,0,0 }, // class a new double[] { 1,0,1, 0,0,0 }, // class a new double[] { 1,1,1, 0,0,0 }, // class a new double[] { 0,0,1, 1,1,0 }, // class b new double[] { 0,0,1, 1,0,0 }, // class b new double[] { 0,0,1, 1,1,0 }, // class b }; double[][] outputs = { new double[] { 1, 0 }, // indicates the inputs at this new double[] { 1, 0 }, // position belongs to class a new double[] { 1, 0 }, new double[] { 0, 1 }, // indicates the inputs at this new double[] { 0, 1 }, // position belongs to class b new double[] { 0, 1 }, }; // Create a Bernoulli activation function var function = new BernoulliFunction(alpha: 0.5); // Create a Restricted Boltzmann Machine for 6 inputs and with 1 hidden neuron var rbm = new RestrictedBoltzmannMachine(function, inputsCount: 6, hiddenNeurons: 2); // Create the learning algorithm for RBMs var teacher = new ContrastiveDivergenceLearning(rbm) { Momentum = 0, LearningRate = 0.1, Decay = 0 }; // learn 5000 iterations for (int i = 0; i < 5000; i++) teacher.RunEpoch(inputs); // Compute the machine answers for the given inputs: double[] a = rbm.Compute(new double[] { 1, 1, 1, 0, 0, 0 }); // { 0.99, 0.00 } double[] b = rbm.Compute(new double[] { 0, 0, 0, 1, 1, 1 }); // { 0.00, 0.99 } // As we can see, the first neuron responds to vectors belonging // to the first class, firing 0.99 when we feed vectors which // have 1s at the beginning. Likewise, the second neuron fires // when the vector belongs to the second class. // We can also generate input vectors given the classes: double[] xa = rbm.GenerateInput(new double[] { 1, 0 }); // { 1, 1, 1, 0, 0, 0 } double[] xb = rbm.GenerateInput(new double[] { 0, 1 }); // { 0, 0, 1, 1, 1, 0 } // As we can see, if we feed an output pattern where the first neuron // is firing and the second isn't, the network generates an example of // a vector belonging to the first class. The same goes for the second // neuron and the second class.