Class: Network

Network(sizes, biasesopt, weightsopt)

new Network(sizes, biasesopt, weightsopt)

Each Network is a collective of neurons functioning as an individual and indepent agent (brain).

Parameters:
Name Type Attributes Description
sizes Array.<number>
biases Array.<number> <optional>
weights Array.<Array.<number>> <optional>
Properties:
Name Type Description
id string
groups Array.<Group>
Source:
Example
const { Network } = require("@liquid-carrot/nn");

const network = new Network([2,2,1]);

network.activate([0,1]);
network.propagate([1]);

Methods

(static) fromGenome(genome) → {Network}

Creates a deep copy of the given genome

Parameters:
Name Type Description
genome Genome
Source:
Returns:
Type
Network

(static) fromShape(inputs, outputs) → {Network}

Creates a network with the given shape (i.e. INPUTSxOUTPUTS). The created network will not have any hidden neurons.

Parameters:
Name Type Description
inputs number

Size of the network's input layer

outputs number

Size of the network's output layer

Source:
Returns:
Type
Network

(static) fromSizes(sizes) → {Network}

Parameters:
Name Type Description
sizes Array.<number>

Array of layer fromSizes

Source:
Returns:
Type
Network
Example
const network = Network.fromSizes([20, 10, 3]);

activate(inputs) → {Array.<number>}

Activates network

Parameters:
Name Type Description
inputs Array.<number>
Source:
Returns:
Type
Array.<number>

propagate(targets) → {number}

Calculates error & updates network weights

Parameters:
Name Type Description
targets Array.<number>
Source:
Returns:

Returns Mean-Squared Error (MSE)

Type
number

toGraph(element, optionsopt)

BROWSER ONLY

Creates a graph of the network using vis-network on the given DOMElement or DOMElement ID.

Parameters:
Name Type Attributes Description
element string | DOMElement

DOMElement, or ID, where graph will ported into

options Object <optional>

vis-network options - learn more

Source:

toJSON() → {Object}

Returns a JSON representation of the network

Source:
Returns:
Type
Object