Class: CooCoo::ActivationFunctions::TanH

Inherits:
Identity show all
Defined in:
lib/coo-coo/activation_functions.rb

Instance Method Summary collapse

Methods inherited from Identity

#initial_weights, method_missing, #name, #to_s

Instance Method Details

#call(x) ⇒ Object



106
107
108
# File 'lib/coo-coo/activation_functions.rb', line 106

def call(x)
  2.0 / (1.0 + (x * -2.0).exp) - 1.0
end

#derivative(x, y = nil) ⇒ Object



110
111
112
113
# File 'lib/coo-coo/activation_functions.rb', line 110

def derivative(x, y = nil)
  y ||= call(x)
  1.0 - y * y
end

#initial_bias(size) ⇒ Object



115
116
117
# File 'lib/coo-coo/activation_functions.rb', line 115

def initial_bias(size)
  CooCoo::Vector.zeros(size)
end

#prep_input(arr) ⇒ Object



119
120
121
# File 'lib/coo-coo/activation_functions.rb', line 119

def prep_input(arr)
  (arr.minmax_normalize(true) * 2.0) - 1.0
end

#prep_output_target(arr) ⇒ Object



123
124
125
# File 'lib/coo-coo/activation_functions.rb', line 123

def prep_output_target(arr)
  prep_input(arr)
end