Class: DNN::Activations::Swish

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

Constant Summary collapse

NMath =
Xumo::NMath

Instance Attribute Summary

Attributes inherited from Layers::Layer

#input_shape

Instance Method Summary collapse

Methods inherited from Layers::Layer

#build, #built?, #initialize, #output_shape, #to_hash

Constructor Details

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

Instance Method Details

#backward(dout) ⇒ Object



62
63
64
# File 'lib/dnn/core/activations.rb', line 62

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

#forward(x) ⇒ Object



57
58
59
60
# File 'lib/dnn/core/activations.rb', line 57

def forward(x)
  @x = x
  @out = x * (1 / (1 + NMath.exp(-x)))
end