Class: DNN::Layers::ReLU

Inherits:
Layer
  • Object
show all
Defined in:
lib/dnn/core/activations.rb

Instance Attribute Summary

Attributes inherited from Layer

#input_shape, #name

Instance Method Summary collapse

Methods inherited from Layer

#build, #built?, call, #call, from_hash, #initialize, #load_hash, #output_shape, #to_hash

Constructor Details

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

Instance Method Details

#backward(dy) ⇒ Object



63
64
65
# File 'lib/dnn/core/activations.rb', line 63

def backward(dy)
  dy * Xumo::SFloat.cast(@x > 0)
end

#forward(x) ⇒ Object



58
59
60
61
# File 'lib/dnn/core/activations.rb', line 58

def forward(x)
  @x = x
  Xumo::SFloat.maximum(0, x)
end