Theano

raw JSON →
1.0.5 verified Mon Apr 27 auth: no python maintenance

Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently, with support for CPUs and GPUs. It was a pioneering library for deep learning but is now in maintenance mode; the latest version is 1.0.5. The project is no longer actively developed, and users are encouraged to migrate to alternatives like TensorFlow, PyTorch, or JAX.

pip install theano
error ImportError: No module named 'theano'
cause Theano is not installed in the current environment.
fix
Run 'pip install theano'.
error AttributeError: module 'theano' has no attribute 'function'
cause Likely using an older version or wrong import path. Theano's 'function' is top-level; ensure you have the correct version installed.
fix
Reinstall with 'pip install --upgrade theano' and verify with 'import theano; print(theano.__version__)'.
error RuntimeError: Cannot compile theano function: No C compiler found
cause Theano requires a working C compiler (like GCC) for compilation.
fix
Install a C compiler (e.g., 'sudo apt-get install gcc' on Ubuntu, or install Xcode command line tools on macOS).
gotcha Theano is no longer actively maintained; the latest release (1.0.5) is from 2021. It may not work with newer Python versions (>=3.10) or modern CUDA toolkits.
fix Consider migrating to PyTorch, TensorFlow, or JAX for active development and support.
breaking Python 3.9 support was dropped in Theano 1.0.5; Python 3.10+ may not be fully compatible. Expect import errors with older Theano versions on newer Python.
fix Use Python 3.8 or 3.9, or upgrade to Theano 1.0.5 and check compatibility.
deprecated Theano's GPU backend (pygpu) is deprecated and may not work with CUDA 11+.
fix Use CPU only or migrate to a library with active GPU support.

Basic symbolic addition using Theano's tensor module.

import theano
import theano.tensor as T

# Define symbolic variables
x = T.dscalar('x')
y = T.dscalar('y')

# Define expression
z = x + y

# Compile function
f = theano.function([x, y], z)

# Execute
print(f(1.5, 2.5))  # Output: 4.0