Class: CooCoo::ActivationFunctions::MinMax

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

Instance Method Summary collapse

Methods inherited from Identity

#initial_bias, #initial_weights, method_missing, #name, #prep_input, #to_s

Instance Method Details

#call(x) ⇒ Object



245
246
247
248
249
250
251
# File 'lib/coo-coo/activation_functions.rb', line 245

def call(x)
  if x.respond_to?(:minmax_normalize)
    x.minmax_normalize
  else
    x
  end
end

#derivative(x, y = nil) ⇒ Object



253
254
255
256
# File 'lib/coo-coo/activation_functions.rb', line 253

def derivative(x, y = nil)
  min, max = x.minmax
  (y || x).class.new((y || x).size, 1.0 / (max - min))
end

#prep_output_target(x) ⇒ Object



258
259
260
# File 'lib/coo-coo/activation_functions.rb', line 258

def prep_output_target(x)
  x.minmax_normalize(true)
end