class CooCoo::ActivationFunctions::ZeroSafeMinMax

Like the {MinMax} but safe when the input is all the same value.

Public Instance Methods

call(x) click to toggle source
# File lib/coo-coo/activation_functions.rb, line 267
def call(x)
  if x.respond_to?(:minmax_normalize)
    x.minmax_normalize(true)
  else
    x
  end
end
derivative(x, y = nil) click to toggle source
# File lib/coo-coo/activation_functions.rb, line 275
def derivative(x, y = nil)
  min, max = x.minmax
  delta = max - min
  if delta == 0.0
    x.zero
  else
    (y || x).class.new((y || x).size, 1.0 / (max - min))
  end
end
prep_output_target(x) click to toggle source
# File lib/coo-coo/activation_functions.rb, line 285
def prep_output_target(x)
  call(x)
end