Giter Site home page Giter Site logo

kc611 / aesara Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aesara-devs/aesara

0.0 0.0 0.0 80.04 MB

Aesara is a fork of the Theano library maintained by the PyMC developers. It was previously named Theano-PyMC.

Home Page: https://theano-pymc.readthedocs.io/en/latest/

License: Other

Shell 0.01% Python 93.05% C 4.80% CSS 0.02% HTML 0.03% Cuda 0.35% Makefile 0.03% C++ 1.41% Cython 0.31%

aesara's Introduction

Tests Status Coverage Gitter

logo

Aesara is a Python library that allows one to define, optimize, and efficiently evaluate mathematical expressions involving multi-dimensional arrays.

Features

  • A hackable, pure-Python codebase
  • Extensible graph framework suitable for rapid development of custom operators and symbolic optimizations
  • Implements an extensible graph transpilation framework that currently provides compilation via C, JAX, and Numba
  • Based on one of the most widely-used Python tensor libraries: Theano

Getting started

import aesara
from aesara import tensor as at

# Declare two symbolic floating-point scalars
a = at.dscalar("a")
b = at.dscalar("b")

# Create a simple example expression
c = a + b

# Convert the expression into a callable object that takes `(a, b)`
# values as input and computes the value of `c`.
f_c = aesara.function([a, b], c)

assert f_c(1.5, 2.5) == 4.0

# Compute the gradient of the example expression with respect to `a`
dc = aesara.grad(c, a)

f_dc = aesara.function([a, b], dc)

assert f_dc(1.5, 2.5) == 1.0

# Compiling functions with `aesara.function` also optimizes
# expression graphs by removing unnecessary operations and
# replacing computations with more efficient ones.

v = at.vector("v")
M = at.matrix("M")

d = a/a + (M + a).dot(v)

aesara.dprint(d)
# Elemwise{add,no_inplace} [id A] ''
#  |InplaceDimShuffle{x} [id B] ''
#  | |Elemwise{true_div,no_inplace} [id C] ''
#  |   |a [id D]
#  |   |a [id D]
#  |dot [id E] ''
#    |Elemwise{add,no_inplace} [id F] ''
#    | |M [id G]
#    | |InplaceDimShuffle{x,x} [id H] ''
#    |   |a [id D]
#    |v [id I]

f_d = aesara.function([a, v, M], d)

# `a/a` -> `1` and the dot product is replaced with a BLAS function
# (i.e. CGemv)
aesara.dprint(f_d)
# Elemwise{Add}[(0, 1)] [id A] ''   5
#  |TensorConstant{(1,) of 1.0} [id B]
#  |CGemv{inplace} [id C] ''   4
#    |AllocEmpty{dtype='float64'} [id D] ''   3
#    | |Shape_i{0} [id E] ''   2
#    |   |M [id F]
#    |TensorConstant{1.0} [id G]
#    |Elemwise{add,no_inplace} [id H] ''   1
#    | |M [id F]
#    | |InplaceDimShuffle{x,x} [id I] ''   0
#    |   |a [id J]
#    |v [id K]
#    |TensorConstant{0.0} [id L]

See the Aesara documentation for in-depth tutorials.

Installation

The latest release of Aesara can be installed from PyPI using pip:

pip install aesara

Or via conda-forge:

conda install -c conda-forge aesara

The current development branch of Aesara can be installed from GitHub, also using pip:

pip install git+https://github.com/aesara-devs/aesara

Support

Many Aesara developers are also PyMC developers, and, since the PyMC developers operate under the NumFOCUS umbrella, if you want to support them financially, consider donating here.

Special thanks to Bram Timmer for the logo.

aesara's People

Contributors

aalmah avatar aam-at avatar abalkin avatar abergeron avatar affanv14 avatar amrithasuresh avatar ballasn avatar brandonwillard avatar breuleux avatar caglar avatar carriepl avatar chienlima avatar dwf avatar f0k avatar gvtulder avatar harlouci avatar hengjean avatar jaberg avatar jlowin avatar khaotik avatar lamblin avatar nicolasbouchard avatar notoraptor avatar nouiz avatar pascanur avatar reyhaneaskari avatar royxue avatar sentient07 avatar slefrancois avatar turian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.