javiche
Small package to enable using ceviche with a JAX optimizer easily.
Install
This package is not yet published. As soon as it is install with:
pip install javiche
or
conda install javiche
How to use
Import the decorator
from javiche import jaxit
decorate your function (will be differentiated using ceviches jacobian -> HIPS autograd)
@jaxit()
def square(A):
"""squares number/array"""
return A**2
Now you can use jax as usual:
grad_fn = jax.grad(square)
grad_fn(2.0)
Array(4., dtype=float32, weak_type=True)
In this toy example that was already possible without the jaxit()
decorator. However jaxit() decorated functions can contain autograd
operators (but no jax operators):
import autograd.numpy as npa
def sin(A):
"""computes sin of number/array using autograds numpy"""
return npa.sin(A)
grad_sin = jax.grad(sin)
try:
print(grad_sin(0.0))
except Exception as e:
print(e)
The numpy.ndarray conversion method __array__() was called on the JAX Tracer object Traced<ConcreteArray(0.0, dtype=float32, weak_type=True)>with<JVPTrace(level=2/0)> with
primal = 0.0
tangent = Traced<ShapedArray(float32[], weak_type=True)>with<JaxprTrace(level=1/0)> with
pval = (ShapedArray(float32[], weak_type=True), None)
recipe = LambdaBinding()
See https://jax.readthedocs.io/en/latest/errors.html#jax.errors.TracerArrayConversionError
@jaxit()
def cos(A):
"""computes sin of number/array using autograds numpy"""
return npa.cos(A)
grad_cos = jax.grad(cos)
try:
print(grad_cos(0.0))
except Exception as e:
print(e)
-0.0
Usecase
This library is intended for use with ceviche, while running a JAX optimization stack as demonstated in the inverse design example
Metadata
Release files for javiche 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| javiche-0.0.6.tar.gz | 10.1 kB | Without provenance | Details for javiche-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| javiche-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for javiche-0.0.6-py3-none-any.whl |
Total release size: 20.0 kB
Release files / javiche-0.0.6.tar.gz
| Download URL | javiche-0.0.6.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b429dbbede453ef3bd5d0b5fb52fb516bb3e5c3249fbc4b8a8cd15280974bc4f
|
|
BLAKE2b-256 checksum How to use checksums |
552e2f9b5a30129894743ea116982a4d1984ba09e2d6d5d5ad24ededea1355d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|
Release files / javiche-0.0.6-py3-none-any.whl
| Download URL | javiche-0.0.6-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
79b29842e01c0befe13e10e2c262a5454525f843160fb7f15b4d8e155cbc90bd
|
|
BLAKE2b-256 checksum How to use checksums |
1f1fadd69e214fcef83cd74aaf10ded79a9e367ed551c5a8732e665809c8ee60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|
Security for javiche 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.