Class: DNN::Layers::Sqrt

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, #initialize, #load_hash, #output_shape, #to_hash

Constructor Details

This class inherits a constructor from DNN::Layers::Layer

Instance Method Details

#backward_node(dy) ⇒ Object



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

def backward_node(dy)
  dy * (1.0 / 2 * Xumo::NMath.sqrt(@x))
end

#forward_node(x) ⇒ Object



106
107
108
109
# File 'lib/dnn/core/layers/math_layers.rb', line 106

def forward_node(x)
  @x = x
  Xumo::NMath.sqrt(x)
end