Class: RubyZero::Core::Functions::Exp

Inherits:
Function
  • Object
show all
Defined in:
lib/rubyzero/core/functions/elementary_functions.rb

Instance Attribute Summary

Attributes inherited from Function

#inputs, #output

Instance Method Summary collapse

Methods inherited from Function

#call, #initialize, #inspect, plot

Constructor Details

This class inherits a constructor from RubyZero::Core::Functions::Function

Instance Method Details

#backward(dy) ⇒ Object



24
25
26
27
# File 'lib/rubyzero/core/functions/elementary_functions.rb', line 24

def backward(dy)
    x1 = @inputs[0]
    return [dy * self.new.call(x1)]
end

#forward(x1) ⇒ Object



17
18
19
20
21
22
# File 'lib/rubyzero/core/functions/elementary_functions.rb', line 17

def forward(x1)
    nmath = x1.device.xmo::NMath
    new_arr = nmath.exp(x1.data)
    new_t = RubyZero::Core::Tensor.new(new_arr, device: x1.device)
    return new_t
end