Class: DNN::Activations::Softplus

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



89
90
91
# File 'lib/dnn/core/activations.rb', line 89

def backward(dout)
  dout * (1 / (1 + Xumo::NMath.exp(-@x)))
end

#forward(x) ⇒ Object



84
85
86
87
# File 'lib/dnn/core/activations.rb', line 84

def forward(x)
  @x = x
  Xumo::NMath.log(1 + Xumo::NMath.exp(x))
end