Class: DNN::Activations::ReLU

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

Instance Attribute Summary

Attributes inherited from Layers::Layer

#input_shape

Instance Method Summary collapse

Methods inherited from Layers::Layer

#build, #built?, #initialize, #output_shape, #to_hash

Constructor Details

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

Instance Method Details

#backward(dout) ⇒ Object



69
70
71
72
73
# File 'lib/dnn/core/activations.rb', line 69

def backward(dout)
  @x[@x > 0] = 1
  @x[@x <= 0] = 0
  dout * @x
end

#forward(x) ⇒ Object



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

def forward(x)
  @x = x.clone
  x[x < 0] = 0
  x
end