lib/dnn/core/activations.rb in ruby-dnn-0.5.10 vs lib/dnn/core/activations.rb in ruby-dnn-0.5.11
- old
+ new
@@ -13,15 +13,14 @@
end
class Tanh < Layer
def forward(x)
- @x = x
- Xumo::NMath.tanh(x)
+ @out = Xumo::NMath.tanh(x)
end
def backward(dout)
- dout * (1.0 / Xumo::NMath.cosh(@x)**2)
+ dout * (1 - @out**2)
end
end
class ReLU < Layer