EagerPy is a thin wrapper around PyTorch, TensorFlow Eager, JAX and NumPy that unifies their interface and thus allows writing code that works natively across all of them.
Project description
EagerPy
EagerPy is a thin wrapper around PyTorch, TensorFlow Eager, JAX and NumPy that unifies their interface and thus allows writing code that works natively across all of them.
Learn more about in the documentation.
EagerPy is now in active use to develop Foolbox Native.
Installation
pip install eagerpy
Example
import eagerpy as ep
import torch
x = torch.tensor([1., 2., 3.])
x = ep.PyTorchTensor(x)
import tensorflow as tf
x = tf.constant([1., 2., 3.])
x = ep.TensorFlowTensor(x)
import jax.numpy as np
x = np.array([1., 2., 3.])
x = ep.JAXTensor(x)
import numpy as np
x = np.array([1., 2., 3.])
x = ep.NumPyTensor(x)
# In all cases, the resulting EagerPy tensor provides the same
# interface. This makes it possible to write code that works natively
# independent of the underlying framework.
# EagerPy tensors provide a lot of functionality through methods, e.g.
x.sum()
x.sqrt()
x.clip(0, 1)
# but EagerPy also provides them as functions, e.g.
ep.sum(x)
ep.sqrt(x)
ep.clip(x, 0, 1)
ep.uniform(x, (3, 3), low=-1., high=1.) # x is needed to infer the framework
Compatibility
We currently test with the following versions:
PyTorch 1.3.1
TensorFlow 2.0.0
JAX 0.1.57
NumPy 1.18.1
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file eagerpy-0.19.0.tar.gz
.
File metadata
- Download URL: eagerpy-0.19.0.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b370f54f53424ec2922e0707469f7b24b5bd4cc94fd91300441212e4400cda9 |
|
MD5 | 1f421c8d3138d7970a816eb5856dc741 |
|
BLAKE2b-256 | 0e4c0b838beab4cc9503a63712342ad040c246211e104c547904434e9c4a42b4 |
File details
Details for the file eagerpy-0.19.0-py3-none-any.whl
.
File metadata
- Download URL: eagerpy-0.19.0-py3-none-any.whl
- Upload date:
- Size: 25.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87ad5afda13435c97cc3b31a97c4c0cd1a0003550e096887f6ad6694d48af906 |
|
MD5 | 76369680d3c1f9e7ad02c757ccae9a36 |
|
BLAKE2b-256 | 362be7d3d8f13538d74b4173fce17f707498bb58ef8390f90fa6d939c09a05e8 |