Class: DNN::Layers::Swish

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



52
53
54
# File 'lib/dnn/core/activations.rb', line 52

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

#forward(x) ⇒ Object



47
48
49
50
# File 'lib/dnn/core/activations.rb', line 47

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