Class: DNN::Layers::Softplus

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

Instance Attribute Summary

Attributes inherited from Layer

#input_shape, #name

Instance Method Summary collapse

Methods inherited from Layer

#build, #built?, call, #call, from_hash, #initialize, #load_hash, #output_shape, #to_hash

Constructor Details

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

Instance Method Details

#backward(dy) ⇒ Object



41
42
43
# File 'lib/dnn/core/activations.rb', line 41

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

#forward(x) ⇒ Object



36
37
38
39
# File 'lib/dnn/core/activations.rb', line 36

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