Class: Chainer::Functions::Math::Exp

Inherits:
Chainer::FunctionNode show all
Defined in:
lib/chainer/functions/math/exp.rb

Instance Attribute Summary

Attributes inherited from Chainer::FunctionNode

#inputs, #outputs, #rank

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Chainer::FunctionNode

#apply, #backward_accumulate, #forward_cpu, #get_retained_inputs, #get_retained_outputs, #initialize, #output_data, #retain_inputs, #retain_outputs, #unchain

Constructor Details

This class inherits a constructor from Chainer::FunctionNode

Class Method Details

.exp(x) ⇒ Object

Elementwise exponential function.



6
7
8
# File 'lib/chainer/functions/math/exp.rb', line 6

def self.exp(x)
  self.new.apply([x]).first
end

Instance Method Details

#backward(indexes, gy) ⇒ Object



21
22
23
24
# File 'lib/chainer/functions/math/exp.rb', line 21

def backward(indexes, gy)
  y = get_retained_outputs.first
  [y * gy.first]
end

#forward(x) ⇒ Object



14
15
16
17
18
19
# File 'lib/chainer/functions/math/exp.rb', line 14

def forward(x)
  retain_inputs([])
  retain_outputs([0])
  xm = Chainer.get_array_module(x.first)
  [Utils::Array.force_array(xm::NMath.exp(x.first))]
end

#labelObject



10
11
12
# File 'lib/chainer/functions/math/exp.rb', line 10

def label
  'exp'
end