Class: DNN::Activations::Softsign

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

Instance Method Summary collapse

Methods inherited from Layers::Layer

#build, #built?, #initialize, #prev_layer, #shape, #to_hash

Constructor Details

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

Instance Method Details

#backward(dout) ⇒ Object



77
78
79
# File 'lib/dnn/core/activations.rb', line 77

def backward(dout)
  dout * (1 / (1 + @x.abs)**2)
end

#forward(x) ⇒ Object



72
73
74
75
# File 'lib/dnn/core/activations.rb', line 72

def forward(x)
  @x = x
  x / (1 + x.abs)
end