{"id":14977807,"url":"https://github.com/pymc-devs/pytensor","last_synced_at":"2026-03-01T14:06:29.735Z","repository":{"id":63560482,"uuid":"561311177","full_name":"pymc-devs/pytensor","owner":"pymc-devs","description":"PyTensor allows you to define, optimize, and efficiently evaluate mathematical expressions involving multi-dimensional arrays.","archived":false,"fork":false,"pushed_at":"2025-05-12T17:09:19.000Z","size":87369,"stargazers_count":459,"open_issues_count":329,"forks_count":129,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-05-12T18:25:12.123Z","etag":null,"topics":["ai","bayesian-inference","computational-science","deep-learning","statistics"],"latest_commit_sha":null,"homepage":"https://pytensor.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"aesara-devs/aesara","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pymc-devs.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":"GOVERNANCE.md","roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"numfocus","custom":["https://numfocus.org/donate-to-pymc"]}},"created_at":"2022-11-03T12:23:08.000Z","updated_at":"2025-05-11T23:25:40.000Z","dependencies_parsed_at":"2024-01-27T11:58:09.055Z","dependency_job_id":"229a4e8e-4d33-49e4-9e0f-ffcf16dcf92d","html_url":"https://github.com/pymc-devs/pytensor","commit_stats":{"total_commits":26339,"total_committers":655,"mean_commits":40.21221374045802,"dds":0.7300580887657087,"last_synced_commit":"e73258b474e790f599ba80f3a4ff81646cf4bc1e"},"previous_names":[],"tags_count":179,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pymc-devs%2Fpytensor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pymc-devs%2Fpytensor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pymc-devs%2Fpytensor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pymc-devs%2Fpytensor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pymc-devs","download_url":"https://codeload.github.com/pymc-devs/pytensor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253805851,"owners_count":21967052,"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":["ai","bayesian-inference","computational-science","deep-learning","statistics"],"created_at":"2024-09-24T13:56:22.091Z","updated_at":"2026-03-01T14:06:29.679Z","avatar_url":"https://github.com/pymc-devs.png","language":"Python","readme":".. image:: https://cdn.rawgit.com/pymc-devs/pytensor/main/doc/images/PyTensor_RGB.svg\n    :height: 100px\n    :alt: PyTensor logo\n    :align: center\n\n|Tests Status| |Coverage|\n\n|Project Name| is a Python library that allows one to define, optimize, and\nefficiently evaluate mathematical expressions involving multi-dimensional arrays.\nIt provides the computational backend for `PyMC \u003chttps://github.com/pymc-devs/pymc\u003e`__.\n\nFeatures\n========\n\n- A hackable, pure-Python codebase\n- Extensible graph framework suitable for rapid development of custom operators and symbolic optimizations\n- Implements an extensible graph transpilation framework that currently provides\n  compilation via C, `JAX \u003chttps://github.com/google/jax\u003e`__, and `Numba \u003chttps://github.com/numba/numba\u003e`__\n- Contrary to PyTorch and TensorFlow, PyTensor maintains a static graph which can be modified in-place to\n  allow for advanced optimizations\n\nGetting started\n===============\n\n.. code-block:: python\n\n    import pytensor\n    from pytensor import tensor as pt\n\n    # Declare two symbolic floating-point scalars\n    a = pt.dscalar(\"a\")\n    b = pt.dscalar(\"b\")\n\n    # Create a simple example expression\n    c = a + b\n\n    # Convert the expression into a callable object that takes `(a, b)`\n    # values as input and computes the value of `c`.\n    f_c = pytensor.function([a, b], c)\n\n    assert f_c(1.5, 2.5) == 4.0\n\n    # Compute the gradient of the example expression with respect to `a`\n    dc = pytensor.grad(c, a)\n\n    f_dc = pytensor.function([a, b], dc)\n\n    assert f_dc(1.5, 2.5) == 1.0\n\n    # Compiling functions with `pytensor.function` also optimizes\n    # expression graphs by removing unnecessary operations and\n    # replacing computations with more efficient ones.\n\n    v = pt.vector(\"v\")\n    M = pt.matrix(\"M\")\n\n    d = a/a + (M + a).dot(v)\n\n    pytensor.dprint(d)\n    #  Add [id A]\n    #  ├─ ExpandDims{axis=0} [id B]\n    #  │  └─ True_div [id C]\n    #  │     ├─ a [id D]\n    #  │     └─ a [id D]\n    #  └─ dot [id E]\n    #     ├─ Add [id F]\n    #     │  ├─ M [id G]\n    #     │  └─ ExpandDims{axes=[0, 1]} [id H]\n    #     │     └─ a [id D]\n    #     └─ v [id I]\n\n    f_d = pytensor.function([a, v, M], d)\n\n    # `a/a` -\u003e `1` and the dot product is replaced with a BLAS function\n    # (i.e. CGemv)\n    pytensor.dprint(f_d)\n    # Add [id A] 5\n    #  ├─ [1.] [id B]\n    #  └─ CGemv{inplace} [id C] 4\n    #     ├─ AllocEmpty{dtype='float64'} [id D] 3\n    #     │  └─ Shape_i{0} [id E] 2\n    #     │     └─ M [id F]\n    #     ├─ 1.0 [id G]\n    #     ├─ Add [id H] 1\n    #     │  ├─ M [id F]\n    #     │  └─ ExpandDims{axes=[0, 1]} [id I] 0\n    #     │     └─ a [id J]\n    #     ├─ v [id K]\n    #     └─ 0.0 [id L]\n\nSee `the PyTensor documentation \u003chttps://pytensor.readthedocs.io/en/latest/\u003e`__ for in-depth tutorials.\n\n\nInstallation\n============\n\nThe latest release of |Project Name| can be installed from PyPI using ``pip``:\n\n::\n\n    pip install pytensor\n\n\nOr via conda-forge:\n\n::\n\n    conda install -c conda-forge pytensor\n\n\nThe current development branch of |Project Name| can be installed from GitHub, also using ``pip``:\n\n::\n\n    pip install git+https://github.com/pymc-devs/pytensor\n\n\nBackground\n==========\n\nPyTensor is a fork of `Aesara \u003chttps://github.com/aesara-devs/aesara\u003e`__, which is a fork of `Theano \u003chttps://github.com/Theano/Theano\u003e`__.\n\nContributing\n============\n\nWe welcome bug reports and fixes and improvements to the documentation.\n\nFor more information on contributing, please see the\n`contributing guide \u003chttps://pytensor.readthedocs.io/en/latest/dev_start_guide.html\u003e`__.\n\nA good place to start contributing is by looking through the issues\n`here \u003chttps://github.com/pymc-devs/pytensor/issues\u003e`__.\n\n\n.. |Project Name| replace:: PyTensor\n.. |Tests Status| image:: https://github.com/pymc-devs/pytensor/workflows/Tests/badge.svg\n  :target: https://github.com/pymc-devs/pytensor/actions?query=workflow%3ATests+branch%3Amain\n.. |Coverage| image:: https://codecov.io/gh/pymc-devs/pytensor/branch/main/graph/badge.svg?token=WVwr8nZYmc\n  :target: https://codecov.io/gh/pymc-devs/pytensor\n","funding_links":["https://github.com/sponsors/numfocus","https://numfocus.org/donate-to-pymc"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpymc-devs%2Fpytensor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpymc-devs%2Fpytensor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpymc-devs%2Fpytensor/lists"}