Constructor
new Neuron(activationopt, learningRateopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
activation |
object |
<optional> |
ACTIVATION.tanh | An object containing an activation function and its first derivative. Typically selected from ACTIVATION. |
learningRate |
number |
<optional> |
INITIALIZE.learningRate() | The rate at which this Neuron should update its Connection weights during training. Usually a very small number (ie 0.01 - 0.5), experiment for optimal results. |
Classes
Members
(static) count :number
A running total number of Neurons created.
A running total number of Neurons created. It is only used to generate unique ids for each Neuron. Creating a new Neuron increments the count but it is never decremented.
Type:
- number
activation :ACTIVATION.tanh|Object|*
Type:
- ACTIVATION.tanh | Object | *
id :number
A unique id beginning at 0 and incremented for every Neuron created.
A unique id beginning at 0 and incremented for every Neuron created.
Type:
- number
incoming :Array
An array of incoming Connections from other Neurons.
An array of incoming Connections from other Neurons.
Type:
- Array
- Source:
- See:
input :number
The input value of the last activation.
The input value of the last activation.
Type:
- number
isBias :boolean
Flag identifying this Neuron as a Bias Neuron.
Flag identifying this Neuron as a Bias Neuron. Bias Neurons are like regular Neurons, except they have no incoming Connections and always output 1.
Type:
- boolean
outgoing :Array
An array of outgoing Connections to other Neurons.
An array of outgoing Connections to other Neurons.
Type:
- Array
- Source:
- See:
output :number
The output value of the last activation.
The output value of the last activation.
Type:
- number
Methods
accumulateGradients()
Calculate and accumulate Connection weight gradients.
Calculate and accumulate Connection weight gradients. Does not update weights. Useful during batch/mini-batch training.
activate(inputopt) → {number}
Activate this Neuron, setting the input value and computing the output.
Activate this Neuron, setting the input value and computing the output. Input Neuron output values will always be equal to their input value. Bias Neurons always output 1. All other Neurons will squash their input value to derive their output.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
input |
number |
<optional> |
If omitted the input value will be calculated from the outputs and weights of the Neurons connected to this Neuron. |
Returns:
- Type
- number
backprop(deltaopt) → {number}
Set this Neuron's delta
value, or compute it if omitted.
Set this Neuron's delta
value, or compute it if omitted.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
delta |
number |
<optional> |
If omitted, the delta value will be calculated from the deltas and weights of the Neurons this Neuron is connected to. |
Returns:
- Type
- number
connect(target, weight)
Connect this Neuron to another Neuron.
Connect this Neuron to another Neuron.
Parameters:
Name | Type | Description |
---|---|---|
target |
Neuron | The Neuron to connect to. |
weight |
number | The strength of the connection. |
isInput() → {boolean}
Determine if this Neuron is an input Neuron.
Determine if this Neuron is an input Neuron.
Returns:
- Type
- boolean
isOutput() → {boolean}
Determine if this Neuron is an output Neuron.
Determine if this Neuron is an output Neuron.
Returns:
- Type
- boolean
updateWeights()
Update Connection weights and reset their accumulated gradients.
Update Connection weights and reset their accumulated gradients.