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

Instance Method Summary collapse

Methods included from LayerNode

#backward, #forward

Methods inherited from Layer

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

Constructor Details

#initialize(index) ⇒ Pow

Returns a new instance of Pow.



88
89
90
91
# File 'lib/dnn/core/layers/math_layers.rb', line 88

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

Instance Method Details

#backward_node(dy) ⇒ Object



98
99
100
# File 'lib/dnn/core/layers/math_layers.rb', line 98

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

#forward_node(x) ⇒ Object



93
94
95
96
# File 'lib/dnn/core/layers/math_layers.rb', line 93

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