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.



166
167
168
169
# File 'lib/dnn/core/layers/math_layers.rb', line 166

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

Instance Method Details

#backward_node(dy) ⇒ Object



176
177
178
# File 'lib/dnn/core/layers/math_layers.rb', line 176

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

#forward_node(x) ⇒ Object



171
172
173
174
# File 'lib/dnn/core/layers/math_layers.rb', line 171

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