Click or drag to resize
Accord.NET (logo)

BernoulliFunction Class

Bernoulli stochastic activation function.
Inheritance Hierarchy
SystemObject
  Accord.Neuro.ActivationFunctionsBernoulliFunction

Namespace:  Accord.Neuro.ActivationFunctions
Assembly:  Accord.Neuro (in Accord.Neuro.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class BernoulliFunction : IStochasticFunction, 
	IActivationFunction
Request Example View Source

The BernoulliFunction type exposes the following members.

Constructors
  NameDescription
Public methodBernoulliFunction
Initializes a new instance of the BernoulliFunction class.
Public methodBernoulliFunction(Double)
Initializes a new instance of the BernoulliFunction class.
Top
Properties
  NameDescription
Public propertyAlpha
Sigmoid's alpha value.
Top
Methods
  NameDescription
Public methodDerivative
Calculates function derivative.
Public methodDerivative2
Calculates function derivative.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodFunction
Calculates function value.
Public methodGenerate
Samples a value from the function given a input value.
Public methodGenerate2
Samples a value from the function given a function output value.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
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 MethodTo(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.)
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.)
Top
Remarks

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.

Examples
// 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
See Also