Class: CooCoo::ActivationFunctions::ShiftedSoftMax

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

Overview

Computes the Softmax function given a Vector but subtracts the maximum value from every element prior to Softmax to prevent overflows:

y_i = e ** (x_i - max(x)) / sum(e ** (x - max(x)))

Instance Method Summary collapse

Methods inherited from Identity

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

Instance Method Details

#call(x) ⇒ Object



233
234
235
# File 'lib/coo-coo/activation_functions.rb', line 233

def call(x)
  super(x - x.max)
end

#derivative(x, y = nil) ⇒ Object



237
238
239
# File 'lib/coo-coo/activation_functions.rb', line 237

def derivative(x, y = nil)
  super(x - x.max, y)
end