lib/dnn/core/utils.rb in ruby-dnn-0.15.0 vs lib/dnn/core/utils.rb in ruby-dnn-0.15.1

- old
+ new

@@ -28,7 +28,12 @@ # Return the result of the softmax function. def self.softmax(x) Losses::SoftmaxCrossEntropy.softmax(x) end + + # Perform numerical differentiation. + def self.numerical_grad(x, func) + (func.(x + 1e-7) - func.(x)) / 1e-7 + end end end