class CooCoo::ActivationFunctions::ShiftedSoftMax

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)))

Public Instance Methods

call(x) click to toggle source
# File lib/coo-coo/activation_functions.rb, line 233
def call(x)
  super(x - x.max)
end
derivative(x, y = nil) click to toggle source
# File lib/coo-coo/activation_functions.rb, line 237
def derivative(x, y = nil)
  super(x - x.max, y)
end