TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

Understand Vectorization for Deep Learning

Compared to a “for” loop, NumPy in Python is over 10,000% faster when dealing with a billion multiplications.

Ahmar Shah, PhD (Oxford)
TDS Archive
Published in
6 min readJul 22, 2022

--

Photo by Markus Krisetya on Unsplash

This post will introduce you to vectorization, and its importance in machine learning (especially deep learning). You will also learn how it is implemented in Python with NumPy, and how much of a difference it makes.

This post assumes a minimal background in linear algebra. You should know what a vector is, what a matrix is, and how we multiply vectors and matrices. Apart from these, I will introduce everything else as we go along.

Why is Vectorization Important?

When it comes to applying machine learning to a given problem, there is typically no deterministic formula that can tell you the precise architecture or hyperparameter that will do well. Regardless of what anyone claims, the procedure is iterative through trial and error. It is, by nature, empirical.

Adapted from Andrew Ng’s Deep Learning Course (Image by Author)

This is why we need to divide our datasets into different parts, a training set, a development set…

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Ahmar Shah, PhD (Oxford)
Ahmar Shah, PhD (Oxford)

Written by Ahmar Shah, PhD (Oxford)

Scientist (several research publications in prestigious journals such as The Lancet, Brain, Thorax, IEEE Transactions), love writing for meaning & impact…

Responses (1)