{"id":13689210,"url":"https://github.com/jonasrauber/eagerpy","last_synced_at":"2025-04-08T08:15:11.723Z","repository":{"id":37686650,"uuid":"217076467","full_name":"jonasrauber/eagerpy","owner":"jonasrauber","description":"PyTorch, TensorFlow, JAX and NumPy — all of them natively using the same code","archived":false,"fork":false,"pushed_at":"2023-03-25T01:30:23.000Z","size":374,"stargazers_count":696,"open_issues_count":21,"forks_count":40,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-01T05:34:31.859Z","etag":null,"topics":["eager-execution","jax","numpy","python","pytorch","tensorflow","tensorflow2"],"latest_commit_sha":null,"homepage":"https://eagerpy.jonasrauber.de","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonasrauber.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["paypal.me/jonasrauber"]}},"created_at":"2019-10-23T14:21:50.000Z","updated_at":"2025-03-31T23:29:09.000Z","dependencies_parsed_at":"2024-04-16T22:50:56.711Z","dependency_job_id":"fd97532d-e2ae-4f4a-a3de-192c493a53be","html_url":"https://github.com/jonasrauber/eagerpy","commit_stats":{"total_commits":328,"total_committers":8,"mean_commits":41.0,"dds":0.07926829268292679,"last_synced_commit":"5b3b37a1e8c49aa3d34b3ed87a5075a20fd50f2f"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasrauber%2Feagerpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasrauber%2Feagerpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasrauber%2Feagerpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonasrauber%2Feagerpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonasrauber","download_url":"https://codeload.github.com/jonasrauber/eagerpy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247801175,"owners_count":20998339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eager-execution","jax","numpy","python","pytorch","tensorflow","tensorflow2"],"created_at":"2024-08-02T15:01:38.219Z","updated_at":"2025-04-08T08:15:11.699Z","avatar_url":"https://github.com/jonasrauber.png","language":"Python","readme":".. raw:: html\n\n   \u003ca href=\"https://eagerpy.jonasrauber.de\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/jonasrauber/eagerpy/master/docs/.vuepress/public/logo_small.png\" align=\"right\" /\u003e\u003c/a\u003e\n\n.. image:: https://badge.fury.io/py/eagerpy.svg\n   :target: https://badge.fury.io/py/eagerpy\n\n.. image:: https://codecov.io/gh/jonasrauber/eagerpy/branch/master/graph/badge.svg\n   :target: https://codecov.io/gh/jonasrauber/eagerpy\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n   :target: https://github.com/ambv/black\n\n==================================================================================\nEagerPy: Writing Code That Works Natively with PyTorch, TensorFlow, JAX, and NumPy\n==================================================================================\n\n`EagerPy \u003chttps://eagerpy.jonasrauber.de\u003e`_ is a **Python framework** that lets you write code that automatically works natively with `PyTorch \u003chttps://pytorch.org\u003e`_, `TensorFlow \u003chttps://www.tensorflow.org\u003e`_, `JAX \u003chttps://github.com/google/jax\u003e`_, and `NumPy \u003chttps://numpy.org\u003e`_. 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.\n\n\n🔥 Design goals\n----------------\n\n- **Native Performance**: EagerPy operations get directly translated into the corresponding native operations.\n- **Fully Chainable**: All functionality is available as methods on the tensor objects and as EagerPy functions.\n- **Type Checking**: Catch bugs before running your code thanks to EagerPy's extensive type annotations.\n\n\n📖 Documentation\n-----------------\n\nLearn more about EagerPy in the `documentation \u003chttps://eagerpy.jonasrauber.de\u003e`_.\n\n\n🚀 Quickstart\n--------------\n\n.. code-block:: bash\n\n   pip install eagerpy\n\nEagerPy 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 \u003chttps://developer.nvidia.com/cuda-zone\u003e`_ versions.\n\n🎉 Example\n-----------\n\n.. code-block:: python\n\n   import torch\n   x = torch.tensor([1., 2., 3., 4., 5., 6.])\n\n   import tensorflow as tf\n   x = tf.constant([1., 2., 3., 4., 5., 6.])\n\n   import jax.numpy as np\n   x = np.array([1., 2., 3., 4., 5., 6.])\n\n   import numpy as np\n   x = np.array([1., 2., 3., 4., 5., 6.])\n\n   # No matter which framwork you use, you can use the same code\n   import eagerpy as ep\n\n   # Just wrap a native tensor using EagerPy\n   x = ep.astensor(x)\n\n   # All of EagerPy's functionality is available as methods\n   x = x.reshape((2, 3))\n   x.flatten(start=1).square().sum(axis=-1).sqrt()\n   # or just: x.flatten(1).norms.l2()\n\n   # and as functions (yes, gradients are also supported!)\n   loss, grad = ep.value_and_grad(loss_fn, x)\n   ep.clip(x + eps * grad, 0, 1)\n\n   # You can even write functions that work transparently with\n   # Pytorch tensors, TensorFlow tensors, JAX arrays, NumPy arrays\n\n   def my_universal_function(a, b, c):\n       # Convert all inputs to EagerPy tensors\n       a, b, c = ep.astensors(a, b, c)\n\n       # performs some computations\n       result = (a + b * c).square()\n\n       # and return a native tensor\n       return result.raw\n\n\n🗺 Use cases\n------------\n\n`Foolbox Native \u003chttps://github.com/bethgelab/foolbox\u003e`_, the latest version of\nFoolbox, a popular adversarial attacks library, has been rewritten from scratch\nusing EagerPy instead of NumPy to achieve native performance on models\ndeveloped in PyTorch, TensorFlow and JAX, all with one code base.\n\nEagerPy is also used by other frameworks to reduce code duplication (e.g. `GUDHI \u003chttps://github.com/GUDHI/gudhi-devel\u003e`_) or to `compare the performance of different frameworks \u003chttps://github.com/jonasrauber/uniformly-sampling-nd-ball\u003e`_.\n\n📄 Citation\n------------\n\nIf you use EagerPy, please cite our `paper \u003chttps://arxiv.org/abs/2008.04175\u003e`_ using the this BibTex entry:\n\n.. code-block::\n\n   @article{rauber2020eagerpy,\n     title={{EagerPy}: Writing Code That Works Natively with {PyTorch}, {TensorFlow}, {JAX}, and {NumPy}},\n     author={Rauber, Jonas and Bethge, Matthias and Brendel, Wieland},\n     journal={arXiv preprint arXiv:2008.04175},\n     year={2020},\n     url={https://eagerpy.jonasrauber.de},\n   }\n\n\n🐍 Compatibility\n-----------------\n\nWe currently test with the following versions:\n\n* PyTorch 1.4.0\n* TensorFlow 2.1.0\n* JAX 0.1.57\n* NumPy 1.18.1\n","funding_links":["paypal.me/jonasrauber"],"categories":["Python","其他_机器学习与深度学习"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonasrauber%2Feagerpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonasrauber%2Feagerpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonasrauber%2Feagerpy/lists"}