Class: NN::ReLU

Inherits:
Object
  • Object
show all
Defined in:
lib/nn.rb

Instance Method Summary collapse

Instance Method Details

#backward(dout) ⇒ Object

[View source]

331
332
333
334
335
# File 'lib/nn.rb', line 331

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

#forward(x) ⇒ Object

[View source]

325
326
327
328
329
# File 'lib/nn.rb', line 325

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