EagerPy is a thin wrapper around PyTorch, TensorFlow Eager 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 and NumPy that unifies their interface and thus allows writing code that works natively across all of them.
Warning: this is work in progress; the tests should run through just fine, but lot’s of features are still missing. Let me know if this project is useful to you and which features are needed.
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 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
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
eagerpy-0.2.3.tar.gz
(4.7 kB
view details)
File details
Details for the file eagerpy-0.2.3.tar.gz
.
File metadata
- Download URL: eagerpy-0.2.3.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 434d968466e66aaaa9bee8341f2cd07f82ba4d2be080243abd809e3b39400b9a |
|
MD5 | e8c3417a7b4c0dab9ea708c79c568253 |
|
BLAKE2b-256 | 429191aa1bbcf1242b8b885028a5c1bfef6ac938cd35c089def47e3bce32dd18 |