Class: RubyZero::Core::Functions::Log
- Defined in:
- lib/rubyzero/core/functions/elementary_functions.rb
Instance Attribute Summary
Attributes inherited from Function
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
10 11 12 13 |
# File 'lib/rubyzero/core/functions/elementary_functions.rb', line 10 def backward(dy) x1 = @inputs[0] return [dy / x1] end |
#forward(x1) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/rubyzero/core/functions/elementary_functions.rb', line 3 def forward(x1) nmath = x1.device.xmo::NMath new_arr = nmath.log(x1.data) new_t = RubyZero::Core::Tensor.new(new_arr, device: x1.device) return new_t end |