move SquaredHalved to core

This commit is contained in:
Connor Olding 2017-07-25 22:14:17 +00:00
parent f43063928e
commit 5d9efa71c1
2 changed files with 7 additions and 7 deletions

7
onn.py
View file

@ -32,13 +32,6 @@ def init_gaussian_unit(size, ins, outs):
# Loss functions {{{1
class SquaredHalved(ResidualLoss):
def f(self, r):
return np.square(r) / 2
def df(self, r):
return r
class SomethingElse(ResidualLoss):
# generalizes Absolute and SquaredHalved.
# plot: https://www.desmos.com/calculator/fagjg9vuz7

View file

@ -215,6 +215,13 @@ class ResidualLoss(Loss):
ret = self.df(p - y) / len(y)
return ret
class SquaredHalved(ResidualLoss):
def f(self, r):
return np.square(r) / 2
def df(self, r):
return r
class Squared(ResidualLoss):
def f(self, r):
return np.square(r)