Add CustomFuncFit into problem; Add related examples

This commit is contained in:
root
2024-07-11 18:32:08 +08:00
parent 3cb5fbf581
commit be6a67d7e2
15 changed files with 241 additions and 437 deletions

View File

@@ -31,6 +31,7 @@ name2sympy = {
"maxabs": SympyMaxabs,
"mean": SympyMean,
"clip": SympyClip,
"square": SympySquare,
}

View File

@@ -69,6 +69,10 @@ class Act:
z = jnp.clip(z, -10, 10)
return jnp.exp(z)
@staticmethod
def square(z):
return jnp.pow(z, 2)
@staticmethod
def abs(z):
z = jnp.clip(z, -1, 1)

View File

@@ -184,6 +184,12 @@ class SympyExp(sp.Function):
return rf"\mathrm{{exp}}\left({sp.latex(self.args[0])}\right)"
class SympySquare(sp.Function):
@classmethod
def eval(cls, z):
return sp.Pow(z, 2)
class SympyAbs(sp.Function):
@classmethod
def eval(cls, z):