Comments (4)
Fixed, confirmed! Mod
seems to be the issue indeed.
from pysr.
I have no idea why sqrt(Abs(x1) + 2)
is appearing as an output of your equation search... PySR should not find integers, only real numbers. But let me try to reproduce this...
By the way; some of the operators you are using are not actually implemented in the torch export, so it won't work anyways. You can add them as with, e.g., extra_torch_mappings={'atanh_clip': ...}
. (I should give a better error for this). It also looks like this argument was also not transferring to the torch export; I'll add this now.
Also - that many operators and features will make the search very very slow. As a rule of thumb, the search will take O(factorial(M * N)) slower if you increase the number of operators by N and the number of features by M. There's also some redundant operators among the ones you passed - e.g., pow
is redundant with exp
. You can do feature pre-selection for all equations via the select_k_features
argument (in which case you probably want to split this into multiple PySR runs!). Or use the methods described here to break down your problem: https://arxiv.org/abs/2006.11287.
from pysr.
I can't reproduce your example; it outputs fine for me. Presumably this is because it discovers a different equation. What was the output equation that it tried to convert to torch format?
from pysr.
Update: the thing I said about 'atanh_clip'
is actually incorrect, sorry. It should have worked without that manual mapping. This is because this is equal to:
"atanh_clip": lambda x: sympy.atanh(sympy.Mod(x + 1, 2) - 1)
and each atanh
and Mod
are converted to PyTorch separately.
However, it looks like mod
was not implemented in the torch mapping. I just added it in 4d5aec3 (0.6.8). I think this should be fixed now, but let me know if it does not work!
Also, here's a way to test if an expression will work, without needing to run the full PySR pipeline:
from pysr import sympy2torch
import torch
from sympy import *
import numpy as np
x, y, z = symbols("x y z")
expression = x ** 2 + atanh(Mod(y + 1, 2) - 1) * 3.2 * z
module = sympy2torch(expression, [x, y, z])
print(module)
# >> _SingleSymPyModule(expression=x**2 + 3.2*z*atanh(Mod(y + 1, 2) - 1))
X = torch.rand(100, 3).float() * 10
torch_out = module(X)
true_out = X[:, 0] ** 2 + torch.atanh(torch.remainder(X[:, 1] + 1, 2) - 1) * 3.2 * X[:, 2]
Test it:
np.testing.assert_array_almost_equal(true_out.detach(), torch_out.detach(), decimal=4)
So we can see it gives the same answer for tanh_clip now.
Cheers,
Miles
from pysr.
Related Issues (20)
- [BUG]: PySR currently incompatible with Python 3.12 HOT 4
- [Feature]: Adding linting to pre-commit hooks HOT 1
- [Feature]: How can I use GPU to accelerate training, like deep learning? HOT 5
- [BUG]: runtime grows to infinity HOT 5
- [Feature]: Self-contained install/user interface HOT 1
- [Feature]: Big Data and partial differential operator
- Understanding accuracy of expressions HOT 5
- Rethinking default behavior for number of iterations
- [Feature]: fixsize HOT 2
- [BUG]: Small typo in documentation HOT 1
- [BUG]: Possible memory leakage & best practices for memory scaling? HOT 5
- [Feature]: Add priori of equation form HOT 1
- [BUG]: PySR can not rediscover X^2 HOT 3
- [Feature]: Composite regressors
- [Feature]: Warn if better linear model available HOT 4
- [BUG]: Using dimensional constraints result in "UndefVarError: `k` not defined" error HOT 4
- Update Head Worker Occupation Warning HOT 3
- Command '['julia', '-e', '...']' returned non-zero exit status 1 HOT 2
- [BUG]: Encounter segmentation faults in running the toy example on RHEL machines HOT 14
- Windows Julia Install - could not load library "libpcre2-8" The specified module could not be found. HOT 19
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysr.