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]

327
328
329
330
331
# File 'lib/nn.rb', line 327

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

#forward(x) ⇒ Object

[View source]

321
322
323
324
325
# File 'lib/nn.rb', line 321

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