dipolar-quantum-gases / jaxfit Goto Github PK
View Code? Open in Web Editor NEWGPU/TPU accelerated nonlinear least-squares curve fitting using JAX
License: BSD 3-Clause "New" or "Revised" License
GPU/TPU accelerated nonlinear least-squares curve fitting using JAX
License: BSD 3-Clause "New" or "Revised" License
For example following code (based on example from jaxfit docs but with @jax.jit
added)
import jax
from jaxfit import CurveFit
@jax.jit
def linear(x, m, b): # fit function
return m * x + b
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
cf = CurveFit()
popt, pcov = cf.curve_fit(linear, x, y)
fails with an error like
Traceback (most recent call last):
File "/home/annulen/./jax_fit.py", line 14, in <module>
popt, pcov = cf.curve_fit(linear, x, y)
File "/home/annulen/venv/jax/lib/python3.10/site-packages/jaxfit/minpack.py", line 228, in curve_fit
res = self.ls.least_squares(f, p0, jac=jac, xdata=xdata, ydata=ydata,
File "/home/annulen/venv/jax/lib/python3.10/site-packages/jaxfit/least_squares.py", line 469, in least_squares
func_update = self.f.__code__.co_code != fun.__code__.co_code
AttributeError: 'PjitFunction' object has no attribute '__code__'. Did you mean: '__call__'?
However, built-in JAX functions like jax.vmap
or jax.grad
work fine with both compiled and non-compiled functions. It would be great if it worked here too.
Hi, I want to perform an vmap iteration over an array, but the "TracerArrayConversionError" appears. I want to ask if it is possible to use this kind of operation or not.
Thanks for your answer.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.