move SquaredHalved to core
This commit is contained in:
parent
f43063928e
commit
5d9efa71c1
2 changed files with 7 additions and 7 deletions
7
onn.py
7
onn.py
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue