Class: DNN::Activations::ReLU

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

Instance Method Summary collapse

Instance Method Details

#backward(dout) ⇒ Object



44
45
46
47
48
# File 'lib/dnn/core/activations.rb', line 44

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

#forward(x) ⇒ Object



38
39
40
41
42
# File 'lib/dnn/core/activations.rb', line 38

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