Class: Group

Group(sizeopt, biasopt)

new Group(sizeopt, biasopt)

A Group is an abstraction of Neuron and a tool for creating and manipulating a group of neurons - with Group we can create neural network layers and and build networks faster than neuron-by-neuron construction.

Parameters:
Name Type Attributes Description
size number <optional>
bias number <optional>
Properties:
Name Type Description
id string
neurons Array.<Neuron>
Source:

Methods

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

Parameters:
Name Type Attributes Description
inputs Array.<number> <optional>
Source:
Returns:
Type
Array.<number>
Example
//===============================================
// One Group (No Hidden Layers) =================
//===============================================
const { Group } = require("@liquidcarrot/nn")

const group = new Group(2);

neuron.activate([0, 0]); // [0, 0]

//===============================================
// Three Groups (Hidden Layers) =================
//===============================================
const { Group } = require("@liquidcarrot/nn")

const input = new Group(2); // Input Neuron (Layer)
const hidden = new Group(2,0.1); // Hidden Neuron (Layer)
const output = new Group(2,0.15); // Output Neuron (Layer)

input.connect(hidden, [0.2,0.25,0.3,0.35]); // Connects input layer to hidden layer
hidden.connect(output, [0.4,0.45,0.5,0.55]); // Connects hidden layer to output layer

input.activate([0,0]); // [0,0]
hidden.activate(); // [0.###, 0.###]
output.activate(); // [0.###, 0.###]

connect(target, weightsopt)

Parameters:
Name Type Attributes Description
target Group
weights Array.<number> <optional>
Source:
Example
//===============================================
// 2x2 (No Weights) =============================
//===============================================
const { Group } = require("@liquidcarrot/nn")

const group = new Group(2);
const other = new Group(2);

group.connect(other);

//===============================================
// 2x2 (Weights) =============================
//===============================================
const { Group } = require("@liquidcarrot/nn")

const group = new Group(2);
const other = new Group(2);

// group[0] -- weights[0] --> other[0]
// group[0] -- weights[1] --> other[1]
// group[1] -- weights[2] --> other[0]
// group[1] -- weights[3] --> other[1]
group.connect(other, [0.1, 0.2, 0.3, 0.4]);

propagate(targetsopt, rateopt) → {Array.<number>}

Parameters:
Name Type Attributes Default Description
targets Array.<number> <optional>
rate number <optional>
0.3
Source:
Returns:
Type
Array.<number>
Example
//===============================================
// One Group (No Hidden Layers) =================
//===============================================
const { Group } = require("@liquidcarrot/nn")

const group = new Group(2);

neuron.activate([0, 0]); // [0, 0]
neuron.propagate([0, 1]); // [0, -1]

//===============================================
// Three Groups (Hidden Layers) =================
//===============================================
const { Group } = require("@liquidcarrot/nn")

const input = new Group(2); // Input Neuron (Layer)
const hidden = new Group(2,0.1); // Hidden Neuron (Layer)
const output = new Group(2,0.15); // Output Neuron (Layer)

input.connect(hidden, [0.2,0.25,0.3,0.35]); // Connects input layer to hidden layer
hidden.connect(output, [0.4,0.45,0.5,0.55]); // Connects hidden layer to output layer

input.activate([0,0]); // [0,0]
hidden.activate(); // [0.###, 0.###]
output.activate(); // [0.###, 0.###]

output.propagate([0, 1]); //  [0, -1]
hidden.propagate(); // [0.###, 0.###]
input.propagate(); // [0.###, 0.###]