encyclopegia.org

Theano (software)

Theano is a Python library and optimizing compiler for manipulating and evaluating mathematical expressions, especially matrix-valued ones.[src] In Theano, computations are expressed using a NumPy-esque syntax and compiled to run efficiently on either CPU or GPU architectures.[src]

Theano is a Python library and optimizing compiler for manipulating and evaluating mathematical expressions, especially matrix-valued ones.[src] In Theano, computations are expressed using a NumPy-esque syntax and compiled to run efficiently on either CPU or GPU architectures.[src] ==Sample code== The following code is the original Theano's example.[src] It defines a computational graph with 2 scalars and of type double and an operation between them (addition) and then creates a Python function f that does the actual computation.[src] import theano from theano import tensor Declare two symbolic floating-point scalars a = tensor.dscalar() b = tensor.dscalar() Create a simple expression c = a + b Convert the expression into a callable object that takes (a, b) values as input and computes a value for c f = theano.function([a, b], c) Bind 1.5 to 'a', 2.5 to 'b', and evaluate 'c' assert 4.0 == f(1.5, 2.5) ===Matrix Multiplication (Dot Product)=== The following code demonstrates how to perform matrix multiplication using Theano, which is essential for linear algebra operations in many machine learning tasks.[src] import theano from theano import tensor Declare two symbolic 2D arrays (matrices) A = tensor.dmatrix("A") B = tensor.dmatrix("B") Define a matrix multiplication (dot product) operation C = tensor.dot(A, B) Create a function that computes the result of the matrix multiplication f = theano.function([A, B], C) Sample matrices A_val = [[1, 2], [3, 4 B_val = [[5, 6], [7, 8 Evaluate the matrix multiplication result = f(A_val, B_val) print(result) import theano from theano import tensor Define symbolic variables x = tensor.dscalar("x") # Input scalar y = tensor.dscalar("y") # Weight scalar Define a simple function (y * x, a simple linear function) z = y * x Compute the gradient of z with respect to x (partial derivative of z with respect to x) dz_dx = tensor.grad(z, x) Create a function to compute the value of z and dz/dx f = theano.function([x, y], [z, dz_dx]) Sample values x_val = 2.0 y_val = 3.0 Compute z and its gradient result = f(x_val, y_val) print("z:", result[0]) # z = y * x = 3 * 2 = 6 print("dz/dx:", result[1]) # dz/dx = y = 3 import theano from theano import tensor as T import numpy as np Define symbolic variables for input and output X = T.matrix("X") # Input features y = T.ivector("y") # Target labels (integer vector) Define the size of the layers input_size = 2 # Number of input features hidden_size = 3 # Number of neurons in the hidden layer output_size = 2 # Number of output classes Initialize weights for input to hidden layer (2x3 matrix) and hidden to output (3x2 matrix) W1 = theano.shared(np.random.randn(input_size, hidden_size), name="W1") b1 = theano.shared(np.zeros(hidden_size), name="b1") W2 = theano.shared(np.random.randn(hidden_size, output_size), name="W2") b2 = theano.shared(np.zeros(output_size), name="b2") Define the forward pass (hidden layer and output layer) hidden_output = T.nnet.sigmoid(T.dot(X, W1) + b1) # Sigmoid activation output = T.nnet.softmax(T.dot(hidden_output, W2) + b2) # Softmax output Define the cost function (cross-entropy) cost = T.nnet.categorical_crossentropy(output, y).mean() Compute gradients grad_W1, grad_b1, grad_W2, grad_b2 = T.grad(cost, [W1, b1, W2, b2]) Create a function to compute the cost and gradients train = theano.function(inputs=[X, y], outputs=[cost, grad_W1, grad_b1, grad_W2, grad_b2]) Sample input data and labels (2 features, 2 samples) X_val = np.array([[0.1, 0.2], [0.3, 0.4 ) y_val = np.array([0, 1]) Train the network for a single step (you would iterate in practice) cost_val, grad_W1_val, grad_b1_val, grad_W2_val, grad_b2_val = train(X_val, y_val) print("Cost:", cost_val) print("Gradients for W1:", grad_W1_val) import theano from theano import tensor as T import numpy as np Declare symbolic arrays A = T.dmatrix("A") B = T.dvector("B") Broadcast B to the shape of A, then add them C = A + B # Broadcasting B to match the shape of A Create a function to evaluate the operation f = theano.function([A, B], C) Sample data (A is a 3x2 matrix, B is a 2-element vector) A_val = np.array([[1, 2], [3, 4], [5, 6 ) B_val = np.array([10, 20]) Evaluate the addition with broadcasting result = f(A_val, B_val) print(result) ==See also== Comparison of deep learning software Comparison of machine learning software Differentiable programming ==References== ==External links== (GitHub) Theano at Deep Learning, Université de Montréal[src]

8 sentences · 8 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Theano (software)." encyclopegia.org, 2026, https://encyclopegia.org/wiki/theano-software. Accessed 28 November 2026.

Chicago

"Theano (software)." encyclopegia.org. Accessed November 28, 2026. https://encyclopegia.org/wiki/theano-software.

APA

encyclopegia.org. (2026). Theano (software). Retrieved November 28, 2026, from https://encyclopegia.org/wiki/theano-software

Accessed November 28, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Ubuntu Software Center

stub · references available

customs software

stub · references available

access software

stub · references available

Free Software Song

stub · references available

software framework

stub · references available

route planning software

stub · references available

data loss prevention software

stub · references available

free and open-source software

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1349193891 · 0.5 · snapshot enwiki-001349193891

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools
  • Careers — open roles: frontier engineers and sales partners
  • Index — every corpus, paper and record
  • Estate guide — what a public data estate is
  • Founder — Lois-Kleinner Alpasan
  • Records — DOIs and external deposits
  • Documents — one-pagers, PDFs and QR codes
  • Brand kit — logos and share images
  • Papers — plain-language briefs with citations
  • Browser — search engine, PWA and bookmarklet
  • Anticloud — the operator and its projects

As seen in Business Insider · 336 outlets · evidence DOIs · plain-language papers

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.