How Shape Information is Handled by Theano?

This recipe explains how shape information is handled by theano.

Recipe Objective - How Shape Information is Handled by Theano?

In Theano, the shape information is currently employed in two ways:
1. When the precise output shape is known in advance, develop quicker C code for the 2d convolution on the CPU and GPU.
2. To eliminate computations from the graph when we simply want to know the shape of a variable rather than its actual value. The Op.infer shape method is used to accomplish this.

Access Face Recognition Project Code using Facenet in Python

For more related projects -

/projects/data-science-projects/tensorflow-projects
/projects/data-science-projects/neural-network-projects

Example -

# Import libraries
import theano
from theano import tensor

# Creating a matrix
a = tensor.dmatrix('a')

# Creaing a function
fun = theano.function([a], (a ** 3).shape)

# Debug
theano.printing.debugprint(fun)

Output -
MakeVector{dtype='int64'} [id A] ''   2
 |Shape_i{0} [id B] ''   1
 | |a [id C]
 |Shape_i{1} [id D] ''   0
   |a [id C]

The output of this compiled function directly shows the shape of the output, instead of any multiplication or power.

What Users are saying..

profile image

Abhinav Agarwal

Graduate Student at Northwestern University
linkedin profile url

I come from Northwestern University, which is ranked 9th in the US. Although the high-quality academics at school taught me all the basics I needed, obtaining practical experience was a challenge.... Read More

Relevant Projects

Topic modelling using Kmeans clustering to group customer reviews
In this Kmeans clustering machine learning project, you will perform topic modelling in order to group customer reviews based on recurring patterns.

Loan Default Prediction Project using Explainable AI ML Models
Loan Default Prediction Project that employs sophisticated machine learning models, such as XGBoost and Random Forest and delves deep into the realm of Explainable AI, ensuring every prediction is transparent and understandable.

Hands-On Approach to Regression Discontinuity Design Python
In this machine learning project, you will learn to implement Regression Discontinuity Design Example in Python to determine the effect of age on Mortality Rate in Python.

OpenCV Project to Master Advanced Computer Vision Concepts
In this OpenCV project, you will learn to implement advanced computer vision concepts and algorithms in OpenCV library using Python.

Digit Recognition using CNN for MNIST Dataset in Python
In this deep learning project, you will build a convolutional neural network using MNIST dataset for handwritten digit recognition.

House Price Prediction Project using Machine Learning in Python
Use the Zillow Zestimate Dataset to build a machine learning model for house price prediction.

Deep Learning Project for Text Detection in Images using Python
CV2 Text Detection Code for Images using Python -Build a CRNN deep learning model to predict the single-line text in a given image.

Learn Hyperparameter Tuning for Neural Networks with PyTorch
In this Deep Learning Project, you will learn how to optimally tune the hyperparameters (learning rate, epochs, dropout, early stopping) of a neural network model in PyTorch to improve model performance.

Medical Image Segmentation Deep Learning Project
In this deep learning project, you will learn to implement Unet++ models for medical image segmentation to detect and classify colorectal polyps.

NLP Project to Build a Resume Parser in Python using Spacy
Use the popular Spacy NLP python library for OCR and text classification to build a Resume Parser in Python.