All Projects → jonasrauber → Eagerpy

jonasrauber / Eagerpy

Licence: mit
PyTorch, TensorFlow, JAX and NumPy — all of them natively using the same code

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Eagerpy

Stats Maths With Python
General statistics, mathematical programming, and numerical/scientific computing scripts and notebooks in Python
Stars: ✭ 381 (-26.73%)
Mutual labels:  numpy
Rust Numpy
PyO3-based Rust binding of NumPy C-API
Stars: ✭ 426 (-18.08%)
Mutual labels:  numpy
Data Science Ipython Notebooks
Data science Python notebooks: Deep learning (TensorFlow, Theano, Caffe, Keras), scikit-learn, Kaggle, big data (Spark, Hadoop MapReduce, HDFS), matplotlib, pandas, NumPy, SciPy, Python essentials, AWS, and various command lines.
Stars: ✭ 22,048 (+4140%)
Mutual labels:  numpy
Workshopscipy
A workshop for scientific computing in Python. ( December 2017 )
Stars: ✭ 391 (-24.81%)
Mutual labels:  numpy
Deep learning nlp
Keras, PyTorch, and NumPy Implementations of Deep Learning Architectures for NLP
Stars: ✭ 407 (-21.73%)
Mutual labels:  numpy
Salib
Sensitivity Analysis Library in Python (Numpy). Contains Sobol, Morris, Fractional Factorial and FAST methods.
Stars: ✭ 436 (-16.15%)
Mutual labels:  numpy
Numpy Tutorial
Numpy beginner tutorial
Stars: ✭ 365 (-29.81%)
Mutual labels:  numpy
Mexican Government Report
Text Mining on the 2019 Mexican Government Report, covering from extracting text from a PDF file to plotting the results.
Stars: ✭ 473 (-9.04%)
Mutual labels:  numpy
Pytablewriter
pytablewriter is a Python library to write a table in various formats: CSV / Elasticsearch / HTML / JavaScript / JSON / LaTeX / LDJSON / LTSV / Markdown / MediaWiki / NumPy / Excel / Pandas / Python / reStructuredText / SQLite / TOML / TSV.
Stars: ✭ 422 (-18.85%)
Mutual labels:  numpy
Geneticalgorithmpython
Source code of PyGAD, a Python 3 library for building the genetic algorithm and training machine learning algorithms (Keras & PyTorch).
Stars: ✭ 435 (-16.35%)
Mutual labels:  numpy
Megengine
MegEngine 是一个快速、可拓展、易于使用且支持自动求导的深度学习框架
Stars: ✭ 4,081 (+684.81%)
Mutual labels:  numpy
Matchering
🎚️ Open Source Audio Matching and Mastering
Stars: ✭ 398 (-23.46%)
Mutual labels:  numpy
Numpycnn
Building Convolutional Neural Networks From Scratch using NumPy
Stars: ✭ 436 (-16.15%)
Mutual labels:  numpy
Quaternion
Add built-in support for quaternions to numpy
Stars: ✭ 387 (-25.58%)
Mutual labels:  numpy
Turbodbc
Turbodbc is a Python module to access relational databases via the Open Database Connectivity (ODBC) interface. The module complies with the Python Database API Specification 2.0.
Stars: ✭ 449 (-13.65%)
Mutual labels:  numpy
Docker Django
A complete docker package for deploying django which is easy to understand and deploy anywhere.
Stars: ✭ 378 (-27.31%)
Mutual labels:  numpy
Matrex
A blazing fast matrix library for Elixir/Erlang with C implementation using CBLAS.
Stars: ✭ 429 (-17.5%)
Mutual labels:  numpy
Pandapy
PandaPy has the speed of NumPy and the usability of Pandas 10x to 50x faster (by @firmai)
Stars: ✭ 474 (-8.85%)
Mutual labels:  numpy
Pynamical
Pynamical is a Python package for modeling and visualizing discrete nonlinear dynamical systems, chaos, and fractals.
Stars: ✭ 458 (-11.92%)
Mutual labels:  numpy
Dsp Theory
Theory of digital signal processing (DSP): signals, filtration (IIR, FIR, CIC, MAF), transforms (FFT, DFT, Hilbert, Z-transform) etc.
Stars: ✭ 437 (-15.96%)
Mutual labels:  numpy

.. raw:: html

.. image:: https://badge.fury.io/py/eagerpy.svg :target: https://badge.fury.io/py/eagerpy

.. image:: https://codecov.io/gh/jonasrauber/eagerpy/branch/master/graph/badge.svg :target: https://codecov.io/gh/jonasrauber/eagerpy

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/ambv/black

================================================================================== EagerPy: Writing Code That Works Natively with PyTorch, TensorFlow, JAX, and NumPy

EagerPy <https://eagerpy.jonasrauber.de>_ is a Python framework that lets you write code that automatically works natively with PyTorch <https://pytorch.org>, TensorFlow <https://www.tensorflow.org>, JAX <https://github.com/google/jax>, and NumPy <https://numpy.org>. EagerPy is also great when you work with just one framework but prefer a clean and consistent API that is fully chainable, provides extensive type annotions and lets you write beautiful code.

🔥 Design goals

  • Native Performance: EagerPy operations get directly translated into the corresponding native operations.
  • Fully Chainable: All functionality is available as methods on the tensor objects and as EagerPy functions.
  • Type Checking: Catch bugs before running your code thanks to EagerPy's extensive type annotations.

📖 Documentation

Learn more about EagerPy in the documentation <https://eagerpy.jonasrauber.de>_.

🚀 Quickstart

.. code-block:: bash

pip install eagerpy

EagerPy requires Python 3.6 or newer. Besides that, all essential dependencies are automatically installed. To use it with PyTorch, TensorFlow, JAX, or NumPy, the respective framework needs to be installed separately. These frameworks are not declared as dependencies because not everyone wants to use and thus install all of them and because some of these packages have different builds for different architectures and CUDA <https://developer.nvidia.com/cuda-zone>_ versions.

🎉 Example

.. code-block:: python

import torch x = torch.tensor([1., 2., 3., 4., 5., 6.])

import tensorflow as tf x = tf.constant([1., 2., 3., 4., 5., 6.])

import jax.numpy as np x = np.array([1., 2., 3., 4., 5., 6.])

import numpy as np x = np.array([1., 2., 3., 4., 5., 6.])

No matter which framwork you use, you can use the same code

import eagerpy as ep

Just wrap a native tensor using EagerPy

x = ep.astensor(x)

All of EagerPy's functionality is available as methods

x = x.reshape((2, 3)) x.flatten(start=1).square().sum(axis=-1).sqrt()

or just: x.flatten(1).norms.l2()

and as functions (yes, gradients are also supported!)

loss, grad = ep.value_and_grad(loss_fn, x) ep.clip(x + eps * grad, 0, 1)

You can even write functions that work transparently with

Pytorch tensors, TensorFlow tensors, JAX arrays, NumPy arrays

def my_universal_function(a, b, c): # Convert all inputs to EagerPy tensors a, b, c = ep.astensors(a, b, c)

   # performs some computations
   result = (a + b * c).square()

   # and return a native tensor
   return result.raw

🗺 Use cases

Foolbox Native <https://github.com/bethgelab/foolbox>_, the latest version of Foolbox, a popular adversarial attacks library, has been rewritten from scratch using EagerPy instead of NumPy to achieve native performance on models developed in PyTorch, TensorFlow and JAX, all with one code base.

EagerPy is also used by other frameworks to reduce code duplication (e.g. GUDHI <https://github.com/GUDHI/gudhi-devel>) or to compare the performance of different frameworks <https://github.com/jonasrauber/uniformly-sampling-nd-ball>.

📄 Citation

If you use EagerPy, please cite our paper <https://arxiv.org/abs/2008.04175>_ using the this BibTex entry:

.. code-block::

@article{rauber2020eagerpy, title={{EagerPy}: Writing Code That Works Natively with {PyTorch}, {TensorFlow}, {JAX}, and {NumPy}}, author={Rauber, Jonas and Bethge, Matthias and Brendel, Wieland}, journal={arXiv preprint arXiv:2008.04175}, year={2020}, url={https://eagerpy.jonasrauber.de}, }

🐍 Compatibility

We currently test with the following versions:

  • PyTorch 1.4.0
  • TensorFlow 2.1.0
  • JAX 0.1.57
  • NumPy 1.18.1
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].