Registry / ai-ml / theano-pymc

theano-pymc

JSON →
library1.1.2pypypiunverified

Theano-PyMC is a Python library that serves as an optimizing compiler for evaluating mathematical expressions on CPUs and GPUs, featuring efficient symbolic differentiation. It is a fork of the original Theano library, specifically maintained by the PyMC developers to support PyMC3. Its current version is 1.1.2, released in January 2021. While PyMC has since transitioned to other backends (Aesara, then PyTensor), Theano-PyMC remains the foundational backend for PyMC3, meaning its release cadence is tied to critical compatibility and bug fixes for that specific PyMC version.

pip install Theano-PyMC
INSTALL
IMPORT
SIG · THEANO-PYMC
T
theano-pymc
ai-mlpythonv1.1.2
Install
9.2s avg
Import
3378ms
Disk
247MB
Pass rate
6/ 10
Env Coverage6 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 9s
py 3.11
✓ —
✓ 8.7s
py 3.12
✕ build_error
✕ build_error
py 3.13
✕ build_error
✕ build_error
py 3.9
✓ —
✓ 9.95s
247MB installed
● package 247MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

theano
import theano
tensor
import theano.tensor as tt
import theano.tensor as T
While 'T' was common in older Theano examples, 'tt' is now the widely adopted convention, especially within the PyMC ecosystem.
function
from theano import function
Used to compile symbolic expressions into callable Python functions.
shared
from theano import shared
Used for variables whose values can be changed after the function is compiled, often for model parameters or observed data in iterative computations.

This quickstart demonstrates how to define symbolic variables, construct a mathematical expression, and compile it into an efficient, callable function using `theano.function`. It also shows the use of `theano.shared` variables, which allow their underlying numerical value to be updated without recompiling the Theano function, crucial for iterative algorithms or fitting models with changing data.

import theano import theano.tensor as tt from theano import function # Define symbolic variables x = tt.dscalar('x') # A double-precision scalar y = tt.dscalar('y') # Define a symbolic expression z = x ** 2 + y # Compile the expression into a callable function f = function([x, y], z) # Evaluate the function with numerical values result = f(2.0, 3.0) print(f"Result of x^2 + y for x=2, y=3: {result}") # Example with shared variable import numpy as np from theano import shared shared_val = shared(np.array(10.0, dtype=theano.config.floatX), name='shared_val') output = x * shared_val g_func = function([x], output) print(f"Result with shared_val=10 and x=5: {g_func(5.0)}") shared_val.set_value(np.array(20.0, dtype=theano.config.floatX)) print(f"Result with shared_val=20 and x=5: {g_func(5.0)}")
Debug
Known issues
breakingTheano-PyMC's compatibility with NumPy versions above 1.19.x can be problematic due to the deprecation of `np.bool` and other internal changes. Using newer NumPy versions with older Theano-PyMC (or PyMC3 versions that depend on it) will lead to `AttributeError`.
fix
For PyMC3, ensure you are using a compatible NumPy version (e.g., NumPy < 1.20.0). For newer PyMC versions, they have moved to Aesara/PyTensor, which addresses these compatibilities.
affects: <1.1.2 with NumPy >= 1.20.0
gotchaTheano-PyMC relies on C/C++ compilers (like `g++`) for optimal performance by compiling symbolic graphs into efficient machine code. Without a detected compiler, it will silently fall back to slower Python implementations, severely degrading performance.
fix
Ensure `g++` (or an equivalent C/C++ compiler) is installed and correctly configured in your system's PATH. On Linux, install `build-essential`. On Windows, consider MinGW or Visual C++ build tools. Theano's configuration flags can be checked and modified, e.g., `theano.config.cxx = ''` to silence the warning if you intentionally use Python-only execution.
affects: All versions
deprecatedThe broader PyMC project has transitioned from Theano-PyMC to `Aesara` and then `PyTensor` as its primary backend for symbolic computation. While Theano-PyMC remains important for PyMC3, direct new development or feature additions for Theano-PyMC as a standalone library are minimal, focusing on critical fixes for PyMC3.
fix
For new projects or if using PyMC >= 4.0, you should use `PyTensor` (imported as `pytensor`) instead of `theano-pymc`. If maintaining PyMC3 code, Theano-PyMC is the correct backend.
affects: Since PyMC 4.0
Upgrade
Version history
1.1.2latest on PyPI · released Jan 22, 2021
Audit
Dependencies
numpyrequiredCore dependency for multi-dimensional array operations.
scipyoptionalOptional dependency for extended scientific computing functionalities.
g++optionalRequired for C/C++ compilation of optimized Theano functions for performance. Otherwise, Theano defaults to slower Python implementations.
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources
theano-pymc — pip install theano-pymc · libregistry