Documentation
¶
Index ¶
- type Neuron
- func (n *Neuron) Bias() float64
- func (n *Neuron) CalculateDerivativeOutputWrtTotalNetInput() float64
- func (n *Neuron) CalculateError(targetOutput float64) float64
- func (n *Neuron) CalculateOutput(inputs []float64) float64
- func (n *Neuron) CalculatePdErrorWrtTotalNetInputOfOutputNeuron(targetOutput float64) float64
- func (n *Neuron) CalculatePdTotalNetInputWrtWeight(index int) float64
- func (n *Neuron) Output() float64
- func (n *Neuron) SetNewBias(value float64)
- func (n *Neuron) SetNewWeight(value float64, index int)
- func (n *Neuron) String() string
- func (n *Neuron) UpdateWeightsAndBias()
- func (n *Neuron) Weight(index int) float64
- func (n *Neuron) Weights() []float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Neuron ¶
type Neuron struct {
// Holds the partial derivative of error with respect to the total net input.
// This value is only relevant for the output layer neurons.
PdErrorWrtTotalNetInputOfOutputNeuron float64
// contains filtered or unexported fields
}
Neuron type defines a neuron in the neural network.
func (*Neuron) CalculateDerivativeOutputWrtTotalNetInput ¶
CalculateDerivativeOutputWrtTotalNetInput function is used by both hidden and output layer neurons. It returns the derivative (not partial derivative) of a neuron's output with respect to the total net input.
func (*Neuron) CalculateError ¶
CalculateError returns the error in the last output of the neuron.
func (*Neuron) CalculateOutput ¶
CalculateOutput calculates and returns output of a neuron for given inputs.
func (*Neuron) CalculatePdErrorWrtTotalNetInputOfOutputNeuron ¶
CalculatePdErrorWrtTotalNetInputOfOutputNeuron function is only for output layer neurons. It returns the partial differential of output's error with respect to the total net input to the neuron. i.e. ∂Error/∂Input
By applying the chain rule, https://en.wikipedia.org/wiki/Chain_rule ∂Error/∂Input = ∂Error/∂Output * ∂Output/∂Input
func (*Neuron) CalculatePdTotalNetInputWrtWeight ¶
CalculatePdTotalNetInputWrtWeight function is used by both hidden and output layer neurons. It returns the partial derivative of total net input to a neuron with respect to one of its weight i.e. ∂TotalNetInput/∂Weight.
The total net input of a neuron is a weighted summation of all the inputs and their respective weights to the neuron plus the bias of the neuron. Total Net Input = (n Σ ᵢ = 1) ((inputᵢ * weightᵢ) + biasᵢ)
The partial derivative of the total net input with respect to the weight is the input for that particular weight since all the weighted sums and the bias are treated as constants.
func (*Neuron) SetNewBias ¶
SetNewBias function updates the value of newBias of a neuron.
func (*Neuron) SetNewWeight ¶
SetNewWeight function updates the value in the newWeights array at the given index.
func (*Neuron) UpdateWeightsAndBias ¶
func (n *Neuron) UpdateWeightsAndBias()
UpdateWeightsAndBias function update sthe weights and bias of the neuron with the newWeights and newBias values.