Class: RubyZero::Core::Functions::ReLU

Inherits:
Function
  • Object
show all
Defined in:
lib/rubyzero/core/functions/activations.rb

Instance Attribute Summary

Attributes inherited from Function

#inputs, #output

Instance Method Summary collapse

Methods inherited from Function

#call, #initialize, #inspect, plot

Constructor Details

This class inherits a constructor from RubyZero::Core::Functions::Function

Instance Method Details

#backward(dy) ⇒ Object



8
9
10
# File 'lib/rubyzero/core/functions/activations.rb', line 8

def backward(dy)
    return [ @path_through * dy ]
end

#forward(x) ⇒ Object



3
4
5
6
7
# File 'lib/rubyzero/core/functions/activations.rb', line 3

def forward(x)
    @path_through = RubyZero::Core::Tensor.new(x.data > 0)
    @path_through.cast_to(RubyZero::FloatTensor)
    return x * @path_through
end