Module: Neuronet::NoisyBackpropagate

Includes:
Backpropagate
Included in:
NoisyMiddleNeuron, NoisyNeuron, NoisyOutputNeuron
Defined in:
lib/neuronet/noisy_backpropagate.rb

Overview

Noisy Backpropagate

Instance Method Summary collapse

Methods included from Backpropagate

#backpropagate, #backpropagate!, #reset_backpropagated!

Instance Method Details

#update_bias(error) ⇒ Object

rubocop: disable Style/NestedTernaryOperator



9
10
11
12
13
# File 'lib/neuronet/noisy_backpropagate.rb', line 9

def update_bias(error)
  bmax = Config.bias_clamp
  b = bias + (error * (rand + rand))
  self.bias = b.abs > bmax ? (b.positive? ? bmax : -bmax) : b
end

#update_connections(error) ⇒ Object

rubocop: disable Metrics/AbcSize



16
17
18
19
20
21
22
23
24
# File 'lib/neuronet/noisy_backpropagate.rb', line 16

def update_connections(error)
  wmax = Config.weight_clamp
  connections.each do |c|
    n = c.neuron
    w = c.weight + (n.activation * error * (rand + rand))
    c.weight = w.abs > wmax ? (w.positive? ? wmax : -wmax) : w
    n.backpropagate(error)
  end
end