en ru

Docs

NAME

createActFunc - create object that represents an activation function

SYNOPSIS

function createActFunc(actFunc);
function createActFunc(actFunc, p1);
function createActFunc(actFunc, p1, p2);
function createActFunc(actFunc, p1, p2, p3);
function createActFunc(actFunc, p1, p2, p3, p4);
function createActFunc(actFunc, luaFunction, luaDerivative);

DESCRIPTION

The first five implementations are used to create predefined activation functions. Argument actFunc determines function type and how many parameters from p1, p2, p3, p4 does it need. Do not pass less parameters than required.

The last implementation is for custom activation functions. In this case, actFunc must be set to ACT_FUNC.CUSTOM, while luaFunction and luaDerivative must refer to Lua functions, both taking one numeric argument and returning one numeric value. These Lua functions are used to evaluate activation function and it's derivative.

RETURN VALUES

Upon successful completion, createActFunc returns a unique id of newly created object. Otherwise, 0 is returned.

NOTES

Try to work with predefined activation functions, if possible. Using of custom functions significantly slows down overall performance.

Don't forget to call closeId function to release the object when it is no longer needed.

EXAMPLES

To create sigmoid activation function:

sigmoidActFunc = createActFunc(ACT_FUNC.SIGMOID, 1.0);

To create f(x) = x activation function:

linearActFunc = createActFunc(ACT_FUNC.LINEAR, 1.0, 0.0);

To create f(x) = cos(x) activation function:

function customEval(x)
   return math.cos(x);
   end;

function customDirEval(x)
   return -math.sin(x);
   end;

customActFunc = createActFunc(ACT_FUNC.CUSTOM, customEval, customDirEval);

SEE ALSO

ACT_FUNC, createAbstractNeuron, createDigitalNeuron, closeId

Verbatim copying and distribution of this entire article are permitted in any medium, provided this notice is preserved.
Send suggestions, questions and bug reports to neurowombatmail@gmail.com
Copyright © 2009, 2010, 2011, 2012 Andrew Timashov