Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Node

Creates a new neuron/node

Neurons are the basic unit of the neural network. They can be connected together, or used to gate connections between other neurons. A Neuron can perform basically 4 operations: form connections, gate connections, activate and propagate.

For more information check:

Hierarchy

Index

Constructors

constructor

Properties

activation

activation: number

Output value

bias

bias: number

Neuron's bias here

deltaBiasPrevious

deltaBiasPrevious: number

delta bias previous

deltaBiasTotal

deltaBiasTotal: number

delta bias total

derivativeState

derivativeState: number

derivative state

errorGated

errorGated: number

error gated

errorProjected

errorProjected: number

error projected

errorResponsibility

errorResponsibility: number

error responsibility

gated

gated: Set<Connection>

Connections this node gates

id

id: number

Node ID for NEAT

incoming

incoming: Set<Connection>

Incoming connections to this node

index

index: number

index

mask

mask: number

Used for dropout. This is either 0 (ignored) or 1 (included) during training and is used to avoid overfit.

outgoing

outgoing: Set<Connection>

Outgoing connections from this node

prevState

prevState: number

previous state

selfConnection

selfConnection: Connection

A self connection

squash

squash: ActivationType

state

state: number

state

type

type: NodeType

The type of this node.

Methods

activate

  • activate(input?: undefined | number, trace?: boolean): number
  • Actives the node.

    When a neuron activates, it computes its state from all its input connections and 'squashes' it using its activation function, and returns the output (activation).

    You can also provide the activation (a float between 0 and 1) as a parameter, which is useful for neurons in the input layer.

    Parameters

    • Optional input: undefined | number
    • Default value trace: boolean = true

    Returns number

    A neuron's 'Squashed' output value

addGate

  • This node gates (influences) the given connection

    Parameters

    • connection: Connection

      Connection to be gated (influenced) by a neuron

    Returns void

clear

  • clear(): void
  • Clears this node's state information - i.e. resets node and its connections to "factory settings"

    node.clear() is useful for predicting time series.

    Returns void

connect

  • connect(target: Node, weight?: number, twoSided?: boolean): Connection
  • Connects this node to the given node(s)

    Parameters

    • target: Node

      Node(s) to project connection(s) to

    • Default value weight: number = 1

      Initial connection(s) weight

    • Default value twoSided: boolean = false

      If true connect nodes to each other

    Returns Connection

disconnect

  • Disconnects this node from the given node(s)

    Parameters

    • node: Node

      Node(s) to remove connection(s) to

    • Default value twoSided: boolean = false

    Returns Connection

fromJSON

isHiddenNode

  • isHiddenNode(): boolean

isInputNode

  • isInputNode(): boolean

isOutputNode

  • isOutputNode(): boolean

isProjectedBy

  • isProjectedBy(node: Node): boolean
  • Checks if the given node(s) are have outgoing connections to this node

    Parameters

    • node: Node

      Checks if node(s) have outgoing connections into this node

    Returns boolean

    Returns true, if every node(s) has an outgoing connection into this node

isProjectingTo

  • isProjectingTo(node: Node): boolean
  • Checks if this node has an outgoing connection(s) into the given node(s)

    Parameters

    • node: Node

      Checks if this node has outgoing connection(s) into node(s)

    Returns boolean

    Returns true, if this node has an outgoing connection into every node(s)

mutateActivation

  • mutateActivation(allowedActivations?: ActivationType[]): void
  • Mutates the node's activation function

    Parameters

    • Default value allowedActivations: ActivationType[] = Object.values(ALL_ACTIVATIONS)

    Returns void

mutateBias

  • Mutates the node's bias

    Parameters

    • Default value method: ModBiasMutation = new ModBiasMutation()

      The method is needed for the min and max value of the node's bias otherwise a range of [-1,1] is chosen

    Returns void

propagate

  • propagate(target?: undefined | number, options?: { momentum?: undefined | number; rate?: undefined | number; update?: undefined | false | true }): void
  • Backpropagate the error (a.k.a. learn).

    After an activation, you can teach the node what should have been the correct output (a.k.a. train). This is done by backpropagating. Momentum adds a fraction of the previous weight update to the current one. When the gradient keeps pointing in the same direction, this will increase the size of the steps taken towards the minimum.

    If you combine a high learning rate with a lot of momentum, you will rush past the minimum (of the error function) with huge steps. It is therefore often necessary to reduce the global learning rate ยต when using a lot of momentum (m close to 1).

    see

    Regularization Neataptic

    see

    What is backpropagation | YouTube

    Parameters

    • Optional target: undefined | number

      The target value (i.e. "the value the network SHOULD have given")

    • Default value options: { momentum?: undefined | number; rate?: undefined | number; update?: undefined | false | true } = {}

      More options for propagation

      • Optional momentum?: undefined | number

        Momentum adds a fraction of the previous weight update to the current one.

      • Optional rate?: undefined | number
      • Optional update?: undefined | false | true

        When set to false weights won't update, but when set to true after being false the last propagation will include the delta weights of the first "update:false" propagations too.

    Returns void

removeGate

  • Stops this node from gating (manipulating) the given connection(s)

    Parameters

    • connection: Connection

      Connections to remove gate - i.e. remove this node from

    Returns void

setActivationType

  • setActivationType(activation: ActivationType): Node

setBias

  • setBias(bias: number): Node

toJSON

Generated using TypeDoc