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

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

Instance Attribute Summary

Attributes inherited from Chainer::Function

#inputs, #output_data, #outputs, #rank, #retain_after_backward

Instance Method Summary collapse

Methods inherited from Chainer::Function

#call, #forward_cpu, #retain_inputs, #retain_outputs

Constructor Details

#initialize(value) ⇒ PowVarConst

Returns a new instance of PowVarConst.



103
104
105
# File 'lib/chainer/functions/math/basic_math.rb', line 103

def initialize(value)
  @value = value
end

Instance Method Details

#backward(x, gy) ⇒ Object



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

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



107
108
109
# File 'lib/chainer/functions/math/basic_math.rb', line 107

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