BernoulliFunction Class 
Namespace: Accord.Neuro.ActivationFunctions
[SerializableAttribute] public class BernoulliFunction : IStochasticFunction, IActivationFunction
The BernoulliFunction type exposes the following members.
Name  Description  

BernoulliFunction 
Initializes a new instance of the BernoulliFunction class.
 
BernoulliFunction(Double) 
Initializes a new instance of the BernoulliFunction class.

Name  Description  

Derivative 
Calculates function derivative.
 
Derivative2 
Calculates function derivative.
 
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.)  
Function 
Calculates function value.
 
Generate 
Samples a value from the function given a input value.
 
Generate2 
Samples a value from the function given a function output value.
 
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.)  
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.)  
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.)  
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 Matrix.) 
The Bernoulli activation function can be used to create Stochastic Neurons, which can in turn be used to create Deep Belief Networks and Restricted Boltzmann Machines. The use of a Bernoulli function is indicated when the inputs of a problem are discrete, it is, are either 0 or 1. When the inputs are continuous, the use of a GaussianFunction might be more indicated.
As a stochastic activation function, the Bernoulli function is able to generate values following a statistic probability distribution. In this case, the Bernoulli function follows a Bernoulli distribution with its mean given by the output of this class' sigmoidal function.
// Create a Bernoulli function with sigmoid's alpha = 1 BernoulliFunction function = new BernoulliFunction(); // Computes the function output (sigmoid function) double y = function.Function(x: 0.4); // 0.5986876 // Draws a sample from a Bernoulli distribution with // mean given by the function output y (given as before) double z = function.Generate(x: 0.4); // (random, 0 or 1) // Here, z can be either 0 or 1. Since it follows a Bernoulli // distribution with mean 0.59, it is expected to be 1 about // 0.59 of the time. // Now, please note that the above is completely equivalent // to computing the line below (remember, 0.5986876 == y) double w = function.Generate2(y: 0.5986876); // (random, 0 or 1) // We can also compute the derivative of the sigmoid function double d = function.Derivative(x: 0.4); // 0.240260 // Or compute the derivative given the functions' output y double e = function.Derivative2(y: 0.5986876); // 0.240260