Skip to content

Commit dbc7447

Browse files
Rename Theano to Aesara
1 parent 0fd439f commit dbc7447

File tree

112 files changed

+2544
-2490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+2544
-2490
lines changed

Diff for: .github/ISSUE_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ If you have questions about a specific use case, or you are not sure whether thi
1818
## Versions and main components
1919

2020
* PyMC3 Version:
21-
* Theano Version:
21+
* Aesara Version:
2222
* Python Version:
2323
* Operating system:
2424
* How did you install PyMC3: (conda/pip)

Diff for: .github/workflows/arviz_compat.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ${{ matrix.os }}
2020
env:
2121
TEST_SUBSET: ${{ matrix.test-subset }}
22-
THEANO_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
22+
AESARA_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
2323
defaults:
2424
run:
2525
shell: bash -l {0}

Diff for: .github/workflows/jaxtests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ${{ matrix.os }}
1818
env:
1919
TEST_SUBSET: ${{ matrix.test-subset }}
20-
THEANO_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
20+
AESARA_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
2121
defaults:
2222
run:
2323
shell: bash -l {0}

Diff for: .github/workflows/pytest.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
runs-on: ${{ matrix.os }}
6363
env:
6464
TEST_SUBSET: ${{ matrix.test-subset }}
65-
THEANO_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
65+
AESARA_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
6666
defaults:
6767
run:
6868
shell: bash -l {0}

Diff for: .github/workflows/windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ${{ matrix.os }}
1818
env:
1919
TEST_SUBSET: ${{ matrix.test-subset }}
20-
THEANO_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=core2'
20+
AESARA_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=core2'
2121
defaults:
2222
run:
2323
shell: bash -l {0}

Diff for: README.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ Check out the `getting started guide <http://docs.pymc.io/notebooks/getting_star
1515
using Binder!
1616
For questions on PyMC3, head on over to our `PyMC Discourse <https://discourse.pymc.io/>`__ forum.
1717

18-
The future of PyMC3 & Theano
18+
The future of PyMC3 & Aesara
1919
============================
2020

21-
There have been many questions and uncertainty around the future of PyMC3 since Theano
21+
There have been many questions and uncertainty around the future of PyMC3 since Aesara
2222
stopped getting developed by the original authors, and we started experiments with PyMC4.
2323

24-
We are happy to announce that PyMC3 on Theano (which we are `developing further <https://github.com/pymc-devs/Theano-PyMC>`__)
24+
We are happy to announce that PyMC3 on Aesara (which we are `developing further <https://github.com/pymc-devs/aesara>`__)
2525
with a new JAX backend is the future. PyMC4 will not be developed further.
2626

2727
See the `full announcement <https://pymc-devs.medium.com/the-future-of-pymc3-or-theano-is-dead-long-live-theano-d8005f8a0e9b>`__
@@ -39,7 +39,7 @@ Features
3939
- **Variational inference**: `ADVI <http://www.jmlr.org/papers/v18/16-107.html>`__
4040
for fast approximate posterior estimation as well as mini-batch ADVI
4141
for large data sets.
42-
- Relies on `Theano-PyMC <https://theano-pymc.readthedocs.io/en/latest/>`__ which provides:
42+
- Relies on `Aesara <https://aesara.readthedocs.io/en/latest/>`__ which provides:
4343
* Computation optimization and dynamic C or JAX compilation
4444
* Numpy broadcasting and advanced indexing
4545
* Linear algebra operators

Diff for: benchmarks/benchmarks/benchmarks.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
import time
1515
import timeit
1616

17+
import aesara
18+
import aesara.tensor as aet
1719
import arviz as az
1820
import numpy as np
1921
import pandas as pd
20-
import theano
21-
import theano.tensor as tt
2222

2323
import pymc3 as pm
2424

@@ -27,7 +27,7 @@ def glm_hierarchical_model(random_seed=123):
2727
"""Sample glm hierarchical model to use in benchmarks"""
2828
np.random.seed(random_seed)
2929
data = pd.read_csv(pm.get_data("radon.csv"))
30-
data["log_radon"] = data["log_radon"].astype(theano.config.floatX)
30+
data["log_radon"] = data["log_radon"].astype(aesara.config.floatX)
3131
county_idx = data.county_code.values
3232

3333
n_counties = len(data.county.unique())
@@ -61,8 +61,8 @@ def mixture_model(random_seed=1234):
6161
mu = pm.Normal("mu", mu=0.0, sd=10.0, shape=w_true.shape)
6262
enforce_order = pm.Potential(
6363
"enforce_order",
64-
tt.switch(mu[0] - mu[1] <= 0, 0.0, -np.inf)
65-
+ tt.switch(mu[1] - mu[2] <= 0, 0.0, -np.inf),
64+
aet.switch(mu[0] - mu[1] <= 0, 0.0, -np.inf)
65+
+ aet.switch(mu[1] - mu[2] <= 0, 0.0, -np.inf),
6666
)
6767
tau = pm.Gamma("tau", alpha=1.0, beta=1.0, shape=w_true.shape)
6868
pm.NormalMixture("x_obs", w=w, mu=mu, tau=tau, observed=x)

Diff for: docs/source/Advanced_usage_of_Theano_in_PyMC3.rst

+27-27
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
_referenced in docs/source/notebooks/table_of_contents_tutorials.js
55
66
=================================
7-
Advanced usage of Theano in PyMC3
7+
Advanced usage of Aesara in PyMC3
88
=================================
99

1010
Using shared variables
1111
======================
1212

13-
Shared variables allow us to use values in theano functions that are
13+
Shared variables allow us to use values in aesara functions that are
1414
not considered an input to the function, but can still be changed
1515
later. They are very similar to global variables in may ways::
1616

17-
a = tt.scalar('a')
17+
a = aet.scalar('a')
1818
# Create a new shared variable with initial value of 0.1
19-
b = theano.shared(0.1)
20-
func = theano.function([a], a * b)
19+
b = aesara.shared(0.1)
20+
func = aesara.function([a], a * b)
2121
assert func(2.) == 0.2
2222

2323
b.set_value(10.)
@@ -34,7 +34,7 @@ be time consuming if the number of datasets is large)::
3434
true_mu = [np.random.randn() for _ in range(10)]
3535
observed_data = [mu + np.random.randn(20) for mu in true_mu]
3636

37-
data = theano.shared(observed_data[0])
37+
data = aesara.shared(observed_data[0])
3838
with pm.Model() as model:
3939
mu = pm.Normal('mu', 0, 10)
4040
pm.Normal('y', mu=mu, sigma=1, observed=data)
@@ -55,7 +55,7 @@ variable for our observations::
5555
x = np.random.randn(100)
5656
y = x > 0
5757

58-
x_shared = theano.shared(x)
58+
x_shared = aesara.shared(x)
5959

6060
with pm.Model() as model:
6161
coeff = pm.Normal('x', mu=0, sigma=1)
@@ -74,10 +74,10 @@ not possible to change the shape of a shared variable if that would
7474
also change the shape of one of the variables.
7575

7676

77-
Writing custom Theano Ops
77+
Writing custom Aesara Ops
7878
=========================
7979

80-
While Theano includes a wide range of operations, there are cases where
80+
While Aesara includes a wide range of operations, there are cases where
8181
it makes sense to write your own. But before doing this it is a good
8282
idea to think hard if it is actually necessary. Especially if you want
8383
to use algorithms that need gradient information — this includes NUTS and
@@ -87,22 +87,22 @@ debugging skills for the gradients.
8787

8888
Good reasons for defining a custom Op might be the following:
8989

90-
- You require an operation that is not available in Theano and can't
91-
be build up out of existing Theano operations. This could for example
90+
- You require an operation that is not available in Aesara and can't
91+
be build up out of existing Aesara operations. This could for example
9292
include models where you need to solve differential equations or
9393
integrals, or find a root or minimum of a function that depends
9494
on your parameters.
9595
- You want to connect your PyMC3 model to some existing external code.
9696
- After carefully considering different parametrizations and a lot
9797
of profiling your model is still too slow, but you know of a faster
98-
way to compute the gradient than what theano is doing. This faster
98+
way to compute the gradient than what aesara is doing. This faster
9999
way might be anything from clever maths to using more hardware.
100100
There is nothing stopping anyone from using a cluster via MPI in
101101
a custom node, if a part of the gradient computation is slow enough
102102
and sufficiently parallelizable to make the cost worth it.
103103
We would definitely like to hear about any such examples.
104104

105-
Theano has extensive `documentation, <http://deeplearning.net/software/theano/extending/index.html>`_
105+
Aesara has extensive `documentation, <https://aesara.readthedocs.io/en/latest/extending/index.html>`_
106106
about how to write new Ops.
107107

108108

@@ -158,7 +158,7 @@ We can now use `scipy.optimize.newton` to find the root::
158158
def mu_from_theta(theta):
159159
return optimize.newton(func, 1, fprime=jac, args=(theta,))
160160

161-
We could wrap `mu_from_theta` with `theano.compile.ops.as_op` and use gradient-free
161+
We could wrap `mu_from_theta` with `aesara.compile.ops.as_op` and use gradient-free
162162
methods like Metropolis, but to get NUTS and ADVI working, we also
163163
need to define the derivative of `mu_from_theta`. We can find this
164164
derivative using the implicit function theorem, or equivalently we
@@ -181,16 +181,16 @@ We get
181181
\frac{d}{d\theta}\mu(\theta)
182182
= - \frac{\mu(\theta)^2}{1 + \theta\mu(\theta) + e^{-\theta\mu(\theta)}}
183183
184-
Now, we use this to define a theano op, that also computes the gradient::
184+
Now, we use this to define a aesara op, that also computes the gradient::
185185

186-
import theano
187-
import theano.tensor as tt
188-
import theano.tests.unittest_tools
189-
from theano.graph.op import Op
186+
import aesara
187+
import aesara.tensor as aet
188+
import aesara.tests.unittest_tools
189+
from aesara.graph.op import Op
190190

191191
class MuFromTheta(Op):
192-
itypes = [tt.dscalar]
193-
otypes = [tt.dscalar]
192+
itypes = [aet.dscalar]
193+
otypes = [aet.dscalar]
194194

195195
def perform(self, node, inputs, outputs):
196196
theta, = inputs
@@ -201,23 +201,23 @@ Now, we use this to define a theano op, that also computes the gradient::
201201
theta, = inputs
202202
mu = self(theta)
203203
thetamu = theta * mu
204-
return [- g[0] * mu ** 2 / (1 + thetamu + tt.exp(-thetamu))]
204+
return [- g[0] * mu ** 2 / (1 + thetamu + aet.exp(-thetamu))]
205205

206206
If you value your sanity, always check that the gradient is ok::
207207

208-
theano.tests.unittest_tools.verify_grad(MuFromTheta(), [np.array(0.2)])
209-
theano.tests.unittest_tools.verify_grad(MuFromTheta(), [np.array(1e-5)])
210-
theano.tests.unittest_tools.verify_grad(MuFromTheta(), [np.array(1e5)])
208+
aesara.gradient.verify_grad(MuFromTheta(), [np.array(0.2)])
209+
aesara.gradient.verify_grad(MuFromTheta(), [np.array(1e-5)])
210+
aesara.gradient.verify_grad(MuFromTheta(), [np.array(1e5)])
211211

212212
We can now define our model using this new op::
213213

214214
import pymc3 as pm
215215

216-
tt_mu_from_theta = MuFromTheta()
216+
aet_mu_from_theta = MuFromTheta()
217217

218218
with pm.Model() as model:
219219
theta = pm.HalfNormal('theta', sigma=1)
220-
mu = pm.Deterministic('mu', tt_mu_from_theta(theta))
220+
mu = pm.Deterministic('mu', aet_mu_from_theta(theta))
221221
pm.Normal('y', mu=mu, sigma=0.1, observed=[0.2, 0.21, 0.3])
222222

223223
trace = pm.sample()

Diff for: docs/source/Gaussian_Processes.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ which allows users to combine covariance functions into new ones, for example:
113113

114114
After the covariance function is defined, it is now a function that is
115115
evaluated by calling :code:`cov_func(x, x)` (or :code:`mean_func(x)`). Since
116-
PyMC3 is built on top of Theano, it is relatively easy to define and experiment
116+
PyMC3 is built on top of Aesara, it is relatively easy to define and experiment
117117
with non-standard covariance and mean functons. For more information check out
118118
the tutorial on covariance functions.
119119

@@ -158,7 +158,7 @@ other type of random variable. The first argument is the name of the random
158158
variable representing the function we are placing the prior over.
159159
The second argument is the inputs to the function that the prior is over,
160160
:code:`X`. The inputs are usually known and present in the data, but they can
161-
also be PyMC3 random variables. If the inputs are a Theano tensor or a
161+
also be PyMC3 random variables. If the inputs are a Aesara tensor or a
162162
PyMC3 random variable, the :code:`shape` needs to be given.
163163

164164
Usually at this point, inference is performed on the model. The

Diff for: docs/source/Probability_Distributions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ A variable requires at least a ``name`` argument, and zero or more model paramet
2727

2828
p = pm.Beta('p', 1, 1, shape=(3, 3))
2929

30-
Probability distributions are all subclasses of ``Distribution``, which in turn has two major subclasses: ``Discrete`` and ``Continuous``. In terms of data types, a ``Continuous`` random variable is given whichever floating point type is defined by ``theano.config.floatX``, while ``Discrete`` variables are given ``int16`` types when ``theano.config.floatX`` is ``float32``, and ``int64`` otherwise.
30+
Probability distributions are all subclasses of ``Distribution``, which in turn has two major subclasses: ``Discrete`` and ``Continuous``. In terms of data types, a ``Continuous`` random variable is given whichever floating point type is defined by ``aesara.config.floatX``, while ``Discrete`` variables are given ``int16`` types when ``aesara.config.floatX`` is ``float32``, and ``int64`` otherwise.
3131

3232
All distributions in ``pm.distributions`` will have two important methods: ``random()`` and ``logp()`` with the following signatures:
3333

0 commit comments

Comments
 (0)