Class: Expression

Expression(inputs, outputs, rows, columns, levelsBack, arity, kernelSet, seed)

new Expression(inputs, outputs, rows, columns, levelsBack, arity, kernelSet, seed)

Parameters:
Name Type Description
inputs number Number of inputs.
outputs number Number of outputs
rows number Number of rows.
columns number Number of columns.
levelsBack number Maximum number of levels back the connections can be.
arity number The number of incomming connections of a node.
kernelSet KernelSet Instances with the kernels to be used in the expression.
seed number Pseudo random number generator seed.
Properties:
Type Description
Source:

Members

chromosome :Array.<number>

Type:
  • Array.<number>
Source:

Methods

destroy()

Cleans this object from the shared memory with WebAssembly. Must be called before the instance goes out off scope to prevent memory leaks.
Source:

equations(…inputSymbols) → {Array.<string>}

Gets the eqution that is represended by the expression.
Parameters:
Name Type Attributes Description
inputSymbols string <repeatable>
Symbol for the inputs of the expression.
Source:
Returns:
Array with with the equation for every output of the expression.
Type
Array.<string>
Example
expression.equation('a', 'b')
// could for example return ['(a+b)']

evaluate(…inputs) → {Array.<number>}

Calculates the result of the expression with `inputs`.
Parameters:
Name Type Attributes Description
inputs number | Array.<number> <repeatable>
Input to the expression.
Source:
Returns:
The outputs of the expression.
Type
Array.<number>
Examples
expression.evaluate(1, 2, 3)
// could for example return [2, 5]
kernel.evaluate([1, 4], [2, 5], [3, 6])
// could for example return [[2, 4], [5, 8]]

loss(inputs, labels, constantsopt) → {number}

Calculate the loss of the current expression between the provided inputs and the labels. Uses the Mean Square Error to calculate the loss.
Parameters:
Name Type Attributes Description
inputs
labels
constants Array.<number> <optional>
Array with ephemeral constants to be used as inputs together with `inputs`.
Source:
Returns:
The loss.
Type
number