Spaces:
Running
Running
Commit
·
78a18f0
1
Parent(s):
d7b393d
Give sqrtm operators to work with negatives
Browse files- README.md +11 -2
- julia/operators.jl +2 -0
README.md
CHANGED
|
@@ -104,8 +104,12 @@ Now, the symbolic regression code can search using this `special` function
|
|
| 104 |
that squares its left argument and adds it to its right. Make sure
|
| 105 |
all passed functions are valid Julia code, and take one (unary)
|
| 106 |
or two (binary) float32 scalars as input, and output a float32. Operators
|
| 107 |
-
are automatically vectorized.
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
One can also edit `operators.jl`. See below for more options.
|
| 111 |
|
|
@@ -132,6 +136,10 @@ of these and other valid operators are stated below. You can also
|
|
| 132 |
define your own in `operators.jl`, and pass the function
|
| 133 |
name as a string.
|
| 134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
**Binary**
|
| 136 |
|
| 137 |
`plus`, `mult`, `pow`, `div`, `greater`, `mod`, `beta`, `logical_or`,
|
|
@@ -145,6 +153,7 @@ name as a string.
|
|
| 145 |
`logm` (=log(abs(x) + 1e-8)),
|
| 146 |
`logm10` (=log10(abs(x) + 1e-8)),
|
| 147 |
`logm2` (=log2(abs(x) + 1e-8)),
|
|
|
|
| 148 |
`log1p`,
|
| 149 |
`sin`,
|
| 150 |
`cos`,
|
|
|
|
| 104 |
that squares its left argument and adds it to its right. Make sure
|
| 105 |
all passed functions are valid Julia code, and take one (unary)
|
| 106 |
or two (binary) float32 scalars as input, and output a float32. Operators
|
| 107 |
+
are automatically vectorized.
|
| 108 |
+
|
| 109 |
+
We also define `extra_sympy_mappings`,
|
| 110 |
+
so that the SymPy code can understand the output equation from Julia,
|
| 111 |
+
when constructing a useable function. This step is optional, but
|
| 112 |
+
is necessary for the `lambda_format` to work.
|
| 113 |
|
| 114 |
One can also edit `operators.jl`. See below for more options.
|
| 115 |
|
|
|
|
| 136 |
define your own in `operators.jl`, and pass the function
|
| 137 |
name as a string.
|
| 138 |
|
| 139 |
+
Your operator should work with the entire real line (you can use
|
| 140 |
+
abs(x) - see `logm`); otherwise
|
| 141 |
+
the search code will be slowed down with domain errors.
|
| 142 |
+
|
| 143 |
**Binary**
|
| 144 |
|
| 145 |
`plus`, `mult`, `pow`, `div`, `greater`, `mod`, `beta`, `logical_or`,
|
|
|
|
| 153 |
`logm` (=log(abs(x) + 1e-8)),
|
| 154 |
`logm10` (=log10(abs(x) + 1e-8)),
|
| 155 |
`logm2` (=log2(abs(x) + 1e-8)),
|
| 156 |
+
`sqrtm` (=sqrt(abs(x)))
|
| 157 |
`log1p`,
|
| 158 |
`sin`,
|
| 159 |
`cos`,
|
julia/operators.jl
CHANGED
|
@@ -8,7 +8,9 @@ div(x::Float32, y::Float32)::Float32 = x/y
|
|
| 8 |
logm(x::Float32)::Float32 = log(abs(x) + 1f-8)
|
| 9 |
logm2(x::Float32)::Float32 = log2(abs(x) + 1f-8)
|
| 10 |
logm10(x::Float32)::Float32 = log10(abs(x) + 1f-8)
|
|
|
|
| 11 |
neg(x::Float32)::Float32 = -x
|
|
|
|
| 12 |
function greater(x::Float32, y::Float32)::Float32
|
| 13 |
if x > y
|
| 14 |
return 1f0
|
|
|
|
| 8 |
logm(x::Float32)::Float32 = log(abs(x) + 1f-8)
|
| 9 |
logm2(x::Float32)::Float32 = log2(abs(x) + 1f-8)
|
| 10 |
logm10(x::Float32)::Float32 = log10(abs(x) + 1f-8)
|
| 11 |
+
sqrtm(x::Float32)::Float32 = sqrt(abs(x))
|
| 12 |
neg(x::Float32)::Float32 = -x
|
| 13 |
+
|
| 14 |
function greater(x::Float32, y::Float32)::Float32
|
| 15 |
if x > y
|
| 16 |
return 1f0
|