Class: DNN::Layers::Pow

Inherits:
Layer
  • Object
show all
Includes:
LayerNode
Defined in:
lib/dnn/core/layers/math_layers.rb

Instance Attribute Summary

Attributes inherited from Layer

#input_shape, #output_shape

Instance Method Summary collapse

Methods included from LayerNode

#forward

Methods inherited from Layer

#build, #built?, #call, call, #clean, #compute_output_shape, #forward, from_hash, #load_hash, #to_hash

Constructor Details

#initialize(index) ⇒ Pow

Returns a new instance of Pow.



109
110
111
112
# File 'lib/dnn/core/layers/math_layers.rb', line 109

def initialize(index)
  super()
  @index = index
end

Instance Method Details

#backward_node(dy) ⇒ Object



119
120
121
# File 'lib/dnn/core/layers/math_layers.rb', line 119

def backward_node(dy)
  dy * @index * @x**(@index - 1)
end

#forward_node(x) ⇒ Object



114
115
116
117
# File 'lib/dnn/core/layers/math_layers.rb', line 114

def forward_node(x)
  @x = x
  x**@index
end