Category: Theano

  • Conclusion

    The Machine Learning model building involves intensive and repetitive computations involving tensors. These require intensive computing resources. As a regular compiler would provide the optimizations at the local level, it does not generally produce a fast execution code. Theano first builds a computational graph for the entire computation. As the whole picture of computation is…

  • Trivial Training Example

    Theano is quite useful in training neural networks where we have to repeatedly calculate cost, and gradients to achieve an optimum. On large datasets, this becomes computationally intensive. Theano does this efficiently due to its internal optimizations of the computational graph that we have seen earlier. Problem Statement We shall now learn how to use…

  • Functions

    Theano function acts like a hook for interacting with the symbolic graph. A symbolic graph is compiled into a highly efficient execution code. It achieves this by restructuring mathematical equations to make them faster. It compiles some parts of the expression into C language code. It moves some tensors to the GPU, and so on. The efficient…

  • Shared Variables

    Many a times, you would need to create variables which are shared between different functions and also between multiple calls to the same function. To cite an example, while training a neural network you create weights vector for assigning a weight to each feature under consideration. This vector is modified on every iteration during the…

  • Data Types

    Now, that you have understood the basics of Theano, let us begin with the different data types available to you for creating your expressions. The following table gives you a partial list of data types defined in Theano. Data type Theano type Byte bscalar, bvector, bmatrix, brow, bcol, btensor3, btensor4, btensor5, btensor6, btensor7 16-bit integers…

  • Computational Graph

    From the above two examples, you may have noticed that in Theano we create an expression which is eventually evaluated using the Theano function. Theano uses advanced optimization techniques to optimize the execution of an expression. To visualize the computation graph, Theano provides a printing package in its library. Symbolic Graph for Scalar Addition To see the computation…

  • Expression for Matrix Multiplication

    We will compute a dot product of two matrices. The first matrix is of dimension 2 x 3 and the second one is of dimension 3 x 2. The matrices that we used as input and their product are expressed here − [04−11122]⎡⎣⎢3135−1220⎤⎦⎥=[1135020][0−124112][3−1123520]=[1103520] Declaring Variables To write a Theano expression for the above, we first…

  • A Trivial Theano Expression

    Let us begin our journey of Theano by defining and evaluating a trivial expression in Theano. Consider the following trivial expression that adds two scalars − c = a + b Where a, b are variables and c is the expression output. In Theano, defining and evaluating even this trivial expression is tricky. Let us understand the steps to evaluate…

  • Installation

    Theano can be installed on Windows, MacOS, and Linux. The installation in all the cases is trivial. Before you install Theano, you must install its dependencies. The following is the list of dependencies − The optional packages that you may choose to install depending on your needs are − We shall discuss the steps to…

  • Introduction

    Have you developed Machine Learning models in Python? Then, obviously you know the intricacies in developing these models. The development is typically a slow process taking hours and days of computational power. The Machine Learning model development requires lot of mathematical computations. These generally require arithmetic computations especially large matrices of multiple dimensions. These days…