Commit 0c63ff41 authored by Reimar H Leike's avatar Reimar H Leike
Browse files

added hessian to nonlinearities

parent 590406ac
Pipeline #28637 passed with stages
in 10 minutes and 24 seconds
......@@ -26,6 +26,9 @@ class Linear(object):
def derivative(self, x):
return Field.ones_like(x)
def hessian(self, x):
return Field.zeros_like(x)
class Exponential(object):
def __call__(self, x):
......@@ -34,6 +37,9 @@ class Exponential(object):
def derivative(self, x):
return exp(x)
def hessian(self, x):
return exp(x)
class Tanh(object):
def __call__(self, x):
......@@ -42,6 +48,8 @@ class Tanh(object):
def derivative(self, x):
return (1. - tanh(x)**2)
def hessian(self, x):
return - 2. * tanh(x) * (1. - tanh(x)**2)
class PositiveTanh(object):
def __call__(self, x):
......@@ -49,3 +57,6 @@ class PositiveTanh(object):
def derivative(self, x):
return 0.5 * (1. - tanh(x)**2)
def hessian(self, x):
return - tanh(x) * (1. - tanh(x)**2)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment