Class: CooCoo::ActivationFunctions::Normalize
Instance Method Summary
collapse
Methods inherited from Identity
#initial_bias, #initial_weights, method_missing, #name, #prep_input, #to_s
Instance Method Details
293
294
295
296
297
298
299
|
# File 'lib/coo-coo/activation_functions.rb', line 293
def call(x)
if x.respond_to?(:normalize)
x.normalize
else
x.coerce(0)
end
end
|
#derivative(x, y = nil) ⇒ Object
301
302
303
304
305
|
# File 'lib/coo-coo/activation_functions.rb', line 301
def derivative(x, y = nil)
mag = x.magnitude()
y ||= call(x)
1.0 / mag - y * y / mag
end
|
#prep_output_target(x) ⇒ Object
307
308
309
|
# File 'lib/coo-coo/activation_functions.rb', line 307
def prep_output_target(x)
x.normalize
end
|