Skip to main content

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

https://badge.fury.io/py/eagerpy.svg https://codecov.io/gh/jonasrauber/eagerpy/branch/master/graph/badge.svg https://img.shields.io/badge/code%20style-black-000000.svg

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eagerpy-0.20.1.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

eagerpy-0.20.1-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file eagerpy-0.20.1.tar.gz.

File metadata

  • Download URL: eagerpy-0.20.1.tar.gz
  • Upload date:
  • Size: 16.3 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

Hashes for eagerpy-0.20.1.tar.gz
Algorithm Hash digest
SHA256 f428ac7e4a35b3f4a7881955cac987d69381f54885fd2af66408d430dba849ac
MD5 8af3c94e5bf1c2c8dd61b230c51a49b5
BLAKE2b-256 415046ebe455491fbe58014c24c64111ef3b9404eaa6317a10a2aff9a9b8041d

See more details on using hashes here.

File details

Details for the file eagerpy-0.20.1-py3-none-any.whl.

File metadata

  • Download URL: eagerpy-0.20.1-py3-none-any.whl
  • Upload date:
  • Size: 27.2 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

Hashes for eagerpy-0.20.1-py3-none-any.whl
Algorithm Hash digest
SHA256 06a5cc4ba9738a78accd51644ee61e6981bf22ef9b6a562ee2fafcc19ad2985c
MD5 3dc802ad22be9ad7dd6f17ec2f7c3c1e
BLAKE2b-256 1dc7fac91e78f55d9a458d7718c9ca76abb4afa57c9915155c3d1b94624b59e1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page