Class: Chainer::Functions::Math::PowVarConst

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

Instance Attribute Summary

Attributes inherited from Chainer::FunctionNode

#inputs, #outputs, #rank

Instance Method Summary collapse

Methods inherited from Chainer::FunctionNode

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

Constructor Details

#initialize(value) ⇒ PowVarConst

Returns a new instance of PowVarConst.



109
110
111
# File 'lib/chainer/functions/math/basic_math.rb', line 109

def initialize(value)
  @value = value
end

Instance Method Details

#backward(x, gy) ⇒ Object



117
118
119
120
121
# File 'lib/chainer/functions/math/basic_math.rb', line 117

def backward(x, gy)
  val_1 = @value - 1
  gx = @value * (x[0] ** val_1) * gy[0]
  [Utils::Array.force_array(gx)]
end

#forward(x) ⇒ Object



113
114
115
# File 'lib/chainer/functions/math/basic_math.rb', line 113

def forward(x)
  [Utils::Array.force_array(x[0] ** @value)]
end