SlideShare a Scribd company logo
Talk: Hack Linear Algebra with Python for Deep Neural Network
Speaker: Chetan Khatri, Department of Computer Science, University of
Kachchh alumnus.
Lead - Technology, Accionlabs Inc.
In [1]:
from IPython.display import Image
In [2]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 14-24-40.png")
In [3]:
Image(filename="/home/chetan/Downloads/screenshot-towardsdatascience.com-2018-01
-13-07-49-05-835.png")
common linear algebra operations used in Neural Network
Out[2]:
Out[3]:
Say What ? Linear Algebra for Neural Network
In the context of deep learning / Neural network, linear algebra is a mathematical toolbox that offers helpful
techniques for manipulating groups of numbers simultaneously. It provides structures like vectors and
matrices (spreadsheets) to hold these numbers and new rules for how to add, subtract, multiply, and divide
them.
Why is it useful?
It turns complicated problems into simple, intuitive, efficiently calculated problems. Here is an example of
how linear algebra can achieve greater speed and simplicity.
In [4]:
import numpy as np
In [5]:
# Multiply two arrays
x = [1,2,3]
y = [2,3,4]
product = []
for i in range(len(x)):
product.append(x[i]*y[i])
print product
In [6]:
# Linear algebra version
x = np.array([1,2,3])
y = np.array([2,3,4])
x * y
After initializing the arrays, the linear algebra approach was 3x faster.
How is it used in Artificial Neural Network / deep learning ?
Neural networks store weights in matrices. Linear algebra makes matrix operations fast and easy, especially
when training on GPUs. In fact, GPUs were created with vector and matrix operations in mind. Similar to how
images can be represented as arrays of pixels, video games generate compelling gaming experiences using
enormous, constantly evolving matrices. Instead of processing pixels one-by-one, GPUs manipulate entire
matrices of pixels in parallel.
Vectors
[2, 6, 12]
Out[6]:
array([ 2, 6, 12])
Vectors are 1-dimensional arrays of numbers or terms. In geometry, vectors store the magnitude and
direction of a potential change to a point. The vector [3, -2] says go right 3 and down 2. A vector with more
than one dimension is called a matrix.
Vector -> is arrow pointing in a space. What defines a vector: length and direction it's pointing, as long as
length and direction are same you can move all around.
Vectors in geometry
In [7]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 14-36-32.png")
Out[7]:
In [8]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 14-36-36.png")
In [9]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 14-36-42.png")
Out[8]:
Out[9]:
In [10]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 14-39-55.png")
In [11]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-39-53.png")
Vector lives in flat plane is 2 dimensional.
Out[10]:
Out[11]:
In [12]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-41-09.png")
If vector sits in broader space where you and I leave they are 3 Dimensional.
In [13]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-46-00.png")
vector addition & vector multiplication plays important role in linear algebra
positive numbers indicating rightward and upward motion negative numbers indicating leftward and
downward motion
Out[12]:
Out[13]:
Every pair of number gives 1 and only 1 vector. And every vector is associated with 1 and only 1 pair of
number.
3 Dimensions - Z
Z - Parpendicular to both X & Y axis, which orders triplet numbers.
[2 1 3] Move along to how far to X axis. How far to move parellel to Y axis. How far to move parellel to Z axis
In Brief: Vectors typically represent movement from a point. They store both the magnitude and direction of
potential changes to a point. The vector [-2,5] says move left 2 units and up 5 units.
A vector can be applied to any point in space. The vector’s direction equals the slope of the hypotenuse
created moving up 5 and left 2. Its magnitude equals the length of the hypotenuse.
What's going on to space & Ask computer to figure it out numerically.
Scalar operations
Scalar operations involve a vector and a number. You modify the vector in-place by adding, subtracting, or
multiplying the number from all the values in the vector.
Examples: Streaching vector by scalar, Scaling Vector by scalar, Squash in vector by Scalar, Shear vector in
plane geometry
In [14]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-51-02.png")
Out[14]:
In [15]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-52-30.png")
In [16]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-52-33.png")
Out[15]:
Out[16]:
In [17]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-52-40.png")
In [18]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-52-41.png")
Out[17]:
Out[18]:
In [19]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-53-00.png")
In [20]:
Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-53-17.png")
Span: What does the span of two 3d vectors look like ?
All possible linear combination of two vectors. If one vector is already span of other then it's called "Linearly
dependent" for some values of a and b. Each vector adds another dimension to span that's "Linearly
independent" w /= av for all values of a.
Out[19]:
Out[20]:
Basis The basis of a vector space is a set of linearly independent vectors that span the full space. The word
"transformation" suggests that you think using "Movement"
Transformation is linear: If all lines must remain lines, origin remains fixed. Not linear: Some lines get
curved, grid lines remain parellel and evenly spaced.
Elementwise operations
In [21]:
Image(filename="/home/chetan/Music/images/1_g7cc0GkA7xrkhoh-__Ok3g.png")
In elementwise operations like addition, subtraction, and division, values that correspond positionally are
combined to produce a new vector. The 1st value in vector A is paired with the 1st value in vector B. The 2nd
value is paired with the 2nd, and so on. This means the vectors must have equal dimensions to complete the
operation.*
In [22]:
Image(filename="/home/chetan/Music/images/2.png")
In [23]:
y = np.array([1,2,3])
x = np.array([2,3,4])
In [24]:
y + x
Out[21]:
Out[22]:
Out[24]:
array([3, 5, 7])
In [25]:
y - x
In [26]:
y / x
Vector multiplication
There are two types of vector multiplication: Dot product and Hadamard product.
Dot product
The dot product of two vectors is a scalar. Dot product of vectors and matrices (matrix multiplication) is one of
the most important operations in deep learning.
In [27]:
Image(filename="/home/chetan/Music/images/3.png")
In [28]:
y = np.array([1,2,3])
x = np.array([2,3,4])
In [29]:
np.dot(y,x)
Hadamard product
Hadamard Product is elementwise multiplication and it outputs a vector.
Out[25]:
array([-1, -1, -1])
Out[26]:
array([0, 0, 0])
Out[27]:
Out[29]:
20
In [30]:
Image(filename="/home/chetan/Music/images/4.png")
In [31]:
y = np.array([1,2,3])
x = np.array([2,3,4])
In [32]:
y * x
Vector fields
A vector field shows how far the point (x,y) would hypothetically move if we applied a vector function to it like
addition or multiplication. Given a point in space, a vector field shows the power and direction of our
proposed change at a variety of points in a graph.
In [33]:
Image(filename="/home/chetan/Music/images/5.png")
Matrices
A matrix is a rectangular grid of numbers or terms (like an Excel spreadsheet) with special rules for addition,
subtraction, and multiplication.
Out[30]:
Out[32]:
array([ 2, 6, 12])
Out[33]:
Matrix dimensions
We describe the dimensions of a matrix in terms of rows by columns.
In [34]:
Image(filename="/home/chetan/Music/images/6.png")
In [35]:
a = np.array([
[1,2,3],
[4,5,6]
])
In [36]:
a.shape
In [37]:
b = np.array([
[1,2,3]
])
In [38]:
b.shape
Matrix scalar operations
Scalar operations with matrices work the same way as they do for vectors. Simply apply the scalar to every
element in the matrix—add, subtract, divide, multiply, etc.
Out[34]:
Out[36]:
(2, 3)
Out[38]:
(1, 3)
In [39]:
Image(filename="/home/chetan/Music/images/7.png")
In [40]:
a = np.array(
[[1,2],
[3,4]])
In [41]:
a + 1
Matrix elementwise operations
In order to add, subtract, or divide two matrices they must have equal dimensions.* We combine
corresponding values in an elementwise fashion to produce a new matrix.
In [42]:
Image(filename="/home/chetan/Music/images/8.png")
In [43]:
a = np.array([
[1,2],
[3,4]
])
b = np.array([
[1,2],
[3,4]
])
Out[39]:
Out[41]:
array([[2, 3],
[4, 5]])
Out[42]:
In [44]:
a + b
In [45]:
a - b
Numpy broadcasting*
In numpy the dimension requirements for elementwise operations are relaxed via a mechanism called
broadcasting. Two matrices are compatible if the corresponding dimensions in each matrix (rows vs rows,
columns vs columns) meet the following requirements:
1. The dimensions are equal, or
2. One dimension is of size 1
In [46]:
a = np.array([
[1],
[2]
])
b = np.array([
[3,4],
[5,6]
])
c = np.array([
[1,2]
])
In [47]:
# Same no. of rows
# Different no. of columns
# but a has one column so this works
a * b
Out[44]:
array([[2, 4],
[6, 8]])
Out[45]:
array([[0, 0],
[0, 0]])
Out[47]:
array([[ 3, 4],
[10, 12]])
In [48]:
# Same no. of columns
# Different no. of rows
# but c has one row so this works
b * c
In [49]:
# Different no. of columns
# Different no. of rows
# but both a and c meet the
# size 1 requirement rule
a + c
Things get weirder in higher dimensions—3D, 4D, but for now we won’t worry about that. Understanding 2D
operations is a good start.
Matrix Hadamard product
Hadamard product of matrices is an elementwise operation. Values that correspond positionally are
multiplied to produce a new matrix.
In [50]:
Image(filename="/home/chetan/Music/images/9.png")
Out[48]:
array([[ 3, 8],
[ 5, 12]])
Out[49]:
array([[2, 3],
[3, 4]])
Out[50]:
In [51]:
a = np.array(
[[2,3],
[2,3]])
b = np.array(
[[3,4],
[5,6]])
# Uses python's multiply operator
a * b
In numpy you can take the Hadamard product of a matrix and vector as long as their dimensions meet the
requirements of broadcasting.
In [52]:
Image(filename="/home/chetan/Music/images/10.png")
Matrix transpose
Neural networks frequently process weights and inputs of different sizes where the dimensions do not meet
the requirements of matrix multiplication. Matrix transpose provides a way to “rotate” one of the matrices so
that the operation complies with multiplication requirements and can continue. There are two steps to
transpose a matrix: Rotate the matrix right 90° Reverse the order of elements in each row (e.g. [a b c]
becomes [c b a]) As an example, transpose matrix M into T:
Out[51]:
array([[ 6, 12],
[10, 18]])
Out[52]:
In [53]:
Image(filename="/home/chetan/Music/images/11.png")
In [54]:
a = np.array([
[1, 2],
[3, 4]])
a.T
Matrix multiplication
Matrix multiplication specifies a set of rules for multiplying matrices together to produce a new matrix.
Rules
Not all matrices are eligible for multiplication. In addition, there is a requirement on the dimensions of the
resulting matrix output.
1. The number of columns of the 1st matrix must equal the number of rows of the 2nd
2. The product of an M x N matrix and an N x K matrix is an M x K matrix. The new matrix takes the
rows of the 1st and columns of the 2nd
Steps
Matrix multiplication relies on dot product to multiply various combinations of rows and columns.
Out[53]:
Out[54]:
array([[1, 3],
[2, 4]])
In [57]:
Image(filename="/home/chetan/Music/images/12.png")
The operation a1 · b1 means we take the dot product of the 1st row in matrix A (1, 7) and the 1st column in
matrix B (3, 5).
In [58]:
Image(filename="/home/chetan/Music/images/13.png")
Here’s another way to look at it:
In [59]:
Image(filename="/home/chetan/Music/images/14.png")
Test yourself with these examples
Out[57]:
Out[58]:
Out[59]:

More Related Content

What's hot

Computer Vision: Correlation, Convolution, and Gradient
Computer Vision: Correlation, Convolution, and GradientComputer Vision: Correlation, Convolution, and Gradient
Computer Vision: Correlation, Convolution, and Gradient
Ahmed Gad
 
Fuzzy c means manual work
Fuzzy c means manual workFuzzy c means manual work
Fuzzy c means manual work
Dr.E.N.Sathishkumar
 
PCA and SVD in brief
PCA and SVD in briefPCA and SVD in brief
PCA and SVD in brief
N. I. Md. Ashafuddula
 
K means clustering
K means clusteringK means clustering
K means clustering
keshav goyal
 
A Correlative Information-Theoretic Measure for Image Similarity
A Correlative Information-Theoretic Measure for Image SimilarityA Correlative Information-Theoretic Measure for Image Similarity
A Correlative Information-Theoretic Measure for Image Similarity
Farah M. Altufaili
 
Principal component analysis
Principal component analysisPrincipal component analysis
Principal component analysis
Farah M. Altufaili
 
Lda
LdaLda
Pca ankita dubey
Pca ankita dubeyPca ankita dubey
Pca ankita dubey
Ankita Dubey
 
Log polar coordinates
Log polar coordinatesLog polar coordinates
Log polar coordinates
Oğul Göçmen
 
Image recogonization
Image recogonizationImage recogonization
Image recogonizationSANTOSH RATH
 
digital image processing, image processing
digital image processing, image processingdigital image processing, image processing
digital image processing, image processing
Kalyan Acharjya
 
Visualizing the Model Selection Process
Visualizing the Model Selection ProcessVisualizing the Model Selection Process
Visualizing the Model Selection Process
Benjamin Bengfort
 
Wordoku Puzzle Solver - Image Processing Project
Wordoku Puzzle Solver - Image Processing ProjectWordoku Puzzle Solver - Image Processing Project
Wordoku Puzzle Solver - Image Processing Project
Surya Chandra
 
07 dimensionality reduction
07 dimensionality reduction07 dimensionality reduction
07 dimensionality reduction
Marco Quartulli
 
Understandig PCA and LDA
Understandig PCA and LDAUnderstandig PCA and LDA
Understandig PCA and LDA
Dr. Syed Hassan Amin
 
Dimensionality reduction
Dimensionality reductionDimensionality reduction
Dimensionality reduction
Shatakirti Er
 
Design and Implementation of Parallel and Randomized Approximation Algorithms
Design and Implementation of Parallel and Randomized Approximation AlgorithmsDesign and Implementation of Parallel and Randomized Approximation Algorithms
Design and Implementation of Parallel and Randomized Approximation Algorithms
Ajay Bidyarthy
 

What's hot (17)

Computer Vision: Correlation, Convolution, and Gradient
Computer Vision: Correlation, Convolution, and GradientComputer Vision: Correlation, Convolution, and Gradient
Computer Vision: Correlation, Convolution, and Gradient
 
Fuzzy c means manual work
Fuzzy c means manual workFuzzy c means manual work
Fuzzy c means manual work
 
PCA and SVD in brief
PCA and SVD in briefPCA and SVD in brief
PCA and SVD in brief
 
K means clustering
K means clusteringK means clustering
K means clustering
 
A Correlative Information-Theoretic Measure for Image Similarity
A Correlative Information-Theoretic Measure for Image SimilarityA Correlative Information-Theoretic Measure for Image Similarity
A Correlative Information-Theoretic Measure for Image Similarity
 
Principal component analysis
Principal component analysisPrincipal component analysis
Principal component analysis
 
Lda
LdaLda
Lda
 
Pca ankita dubey
Pca ankita dubeyPca ankita dubey
Pca ankita dubey
 
Log polar coordinates
Log polar coordinatesLog polar coordinates
Log polar coordinates
 
Image recogonization
Image recogonizationImage recogonization
Image recogonization
 
digital image processing, image processing
digital image processing, image processingdigital image processing, image processing
digital image processing, image processing
 
Visualizing the Model Selection Process
Visualizing the Model Selection ProcessVisualizing the Model Selection Process
Visualizing the Model Selection Process
 
Wordoku Puzzle Solver - Image Processing Project
Wordoku Puzzle Solver - Image Processing ProjectWordoku Puzzle Solver - Image Processing Project
Wordoku Puzzle Solver - Image Processing Project
 
07 dimensionality reduction
07 dimensionality reduction07 dimensionality reduction
07 dimensionality reduction
 
Understandig PCA and LDA
Understandig PCA and LDAUnderstandig PCA and LDA
Understandig PCA and LDA
 
Dimensionality reduction
Dimensionality reductionDimensionality reduction
Dimensionality reduction
 
Design and Implementation of Parallel and Randomized Approximation Algorithms
Design and Implementation of Parallel and Randomized Approximation AlgorithmsDesign and Implementation of Parallel and Randomized Approximation Algorithms
Design and Implementation of Parallel and Randomized Approximation Algorithms
 

Similar to An Introduction Linear Algebra for Neural Networks and Deep learning

vector application
vector applicationvector application
vector application
rajat shukla
 
CE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdfCE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdf
UmarMustafa13
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
Diksha Trivedi
 
Basic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptxBasic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptx
PremanandS3
 
Vectors.pptx
Vectors.pptxVectors.pptx
Vectors.pptx
NivethithaM9
 
Metric-learn, a Scikit-learn compatible package
Metric-learn, a Scikit-learn compatible packageMetric-learn, a Scikit-learn compatible package
Metric-learn, a Scikit-learn compatible package
William de Vazelhes
 
Matrix algebra in_r
Matrix algebra in_rMatrix algebra in_r
Matrix algebra in_r
Razzaqe
 
Stereo Vision Distance Estimation Employing Canny Edge Detector with Interpol...
Stereo Vision Distance Estimation Employing Canny Edge Detector with Interpol...Stereo Vision Distance Estimation Employing Canny Edge Detector with Interpol...
Stereo Vision Distance Estimation Employing Canny Edge Detector with Interpol...
ZaidHussein6
 
8. Vectors data frames
8. Vectors data frames8. Vectors data frames
8. Vectors data frames
ExternalEvents
 
Matlab solved problems
Matlab solved problemsMatlab solved problems
Matlab solved problems
Make Mannan
 
SessionFour_DataTypesandObjects
SessionFour_DataTypesandObjectsSessionFour_DataTypesandObjects
SessionFour_DataTypesandObjectsHellen Gakuruh
 
Convolutional Neural Network (CNN) presentation from theory to code in Theano
Convolutional Neural Network (CNN) presentation from theory to code in TheanoConvolutional Neural Network (CNN) presentation from theory to code in Theano
Convolutional Neural Network (CNN) presentation from theory to code in Theano
Seongwon Hwang
 
Deep Residual Hashing Neural Network for Image Retrieval
Deep Residual Hashing Neural Network for Image RetrievalDeep Residual Hashing Neural Network for Image Retrieval
Deep Residual Hashing Neural Network for Image Retrieval
Edwin Efraín Jiménez Lepe
 
Introduction to Data Science With R Lab Record
Introduction to Data Science With R Lab RecordIntroduction to Data Science With R Lab Record
Introduction to Data Science With R Lab Record
Lakshmi Sarvani Videla
 
Basics of Digital Images
Basics of  Digital ImagesBasics of  Digital Images
Basics of Digital Images
Saad Al-Momen
 
Performance Comparison of Image Retrieval Using Fractional Coefficients of Tr...
Performance Comparison of Image Retrieval Using Fractional Coefficients of Tr...Performance Comparison of Image Retrieval Using Fractional Coefficients of Tr...
Performance Comparison of Image Retrieval Using Fractional Coefficients of Tr...
CSCJournals
 
FORGERY (COPY-MOVE) DETECTION IN DIGITAL IMAGES USING BLOCK METHOD
FORGERY (COPY-MOVE) DETECTION IN DIGITAL IMAGES USING BLOCK METHODFORGERY (COPY-MOVE) DETECTION IN DIGITAL IMAGES USING BLOCK METHOD
FORGERY (COPY-MOVE) DETECTION IN DIGITAL IMAGES USING BLOCK METHOD
editorijcres
 
Simple Pendulum Experiment and Automatic Survey Grading using Computer Vision
Simple Pendulum Experiment and Automatic Survey Grading using Computer VisionSimple Pendulum Experiment and Automatic Survey Grading using Computer Vision
Simple Pendulum Experiment and Automatic Survey Grading using Computer VisionAnish Patel
 
Solving linear equations from an image using ann
Solving linear equations from an image using annSolving linear equations from an image using ann
Solving linear equations from an image using ann
eSAT Journals
 

Similar to An Introduction Linear Algebra for Neural Networks and Deep learning (20)

vector application
vector applicationvector application
vector application
 
CE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdfCE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdf
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Basic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptxBasic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptx
 
Vectors.pptx
Vectors.pptxVectors.pptx
Vectors.pptx
 
Metric-learn, a Scikit-learn compatible package
Metric-learn, a Scikit-learn compatible packageMetric-learn, a Scikit-learn compatible package
Metric-learn, a Scikit-learn compatible package
 
Matrix algebra in_r
Matrix algebra in_rMatrix algebra in_r
Matrix algebra in_r
 
Stereo Vision Distance Estimation Employing Canny Edge Detector with Interpol...
Stereo Vision Distance Estimation Employing Canny Edge Detector with Interpol...Stereo Vision Distance Estimation Employing Canny Edge Detector with Interpol...
Stereo Vision Distance Estimation Employing Canny Edge Detector with Interpol...
 
8. Vectors data frames
8. Vectors data frames8. Vectors data frames
8. Vectors data frames
 
Matlab solved problems
Matlab solved problemsMatlab solved problems
Matlab solved problems
 
SessionFour_DataTypesandObjects
SessionFour_DataTypesandObjectsSessionFour_DataTypesandObjects
SessionFour_DataTypesandObjects
 
Convolutional Neural Network (CNN) presentation from theory to code in Theano
Convolutional Neural Network (CNN) presentation from theory to code in TheanoConvolutional Neural Network (CNN) presentation from theory to code in Theano
Convolutional Neural Network (CNN) presentation from theory to code in Theano
 
Deep Residual Hashing Neural Network for Image Retrieval
Deep Residual Hashing Neural Network for Image RetrievalDeep Residual Hashing Neural Network for Image Retrieval
Deep Residual Hashing Neural Network for Image Retrieval
 
Introduction to Data Science With R Lab Record
Introduction to Data Science With R Lab RecordIntroduction to Data Science With R Lab Record
Introduction to Data Science With R Lab Record
 
Basics of Digital Images
Basics of  Digital ImagesBasics of  Digital Images
Basics of Digital Images
 
Performance Comparison of Image Retrieval Using Fractional Coefficients of Tr...
Performance Comparison of Image Retrieval Using Fractional Coefficients of Tr...Performance Comparison of Image Retrieval Using Fractional Coefficients of Tr...
Performance Comparison of Image Retrieval Using Fractional Coefficients of Tr...
 
FORGERY (COPY-MOVE) DETECTION IN DIGITAL IMAGES USING BLOCK METHOD
FORGERY (COPY-MOVE) DETECTION IN DIGITAL IMAGES USING BLOCK METHODFORGERY (COPY-MOVE) DETECTION IN DIGITAL IMAGES USING BLOCK METHOD
FORGERY (COPY-MOVE) DETECTION IN DIGITAL IMAGES USING BLOCK METHOD
 
Report
ReportReport
Report
 
Simple Pendulum Experiment and Automatic Survey Grading using Computer Vision
Simple Pendulum Experiment and Automatic Survey Grading using Computer VisionSimple Pendulum Experiment and Automatic Survey Grading using Computer Vision
Simple Pendulum Experiment and Automatic Survey Grading using Computer Vision
 
Solving linear equations from an image using ann
Solving linear equations from an image using annSolving linear equations from an image using ann
Solving linear equations from an image using ann
 

More from Chetan Khatri

Data Science for Beginner by Chetan Khatri and Deptt. of Computer Science, Ka...
Data Science for Beginner by Chetan Khatri and Deptt. of Computer Science, Ka...Data Science for Beginner by Chetan Khatri and Deptt. of Computer Science, Ka...
Data Science for Beginner by Chetan Khatri and Deptt. of Computer Science, Ka...
Chetan Khatri
 
Demystify Information Security & Threats for Data-Driven Platforms With Cheta...
Demystify Information Security & Threats for Data-Driven Platforms With Cheta...Demystify Information Security & Threats for Data-Driven Platforms With Cheta...
Demystify Information Security & Threats for Data-Driven Platforms With Cheta...
Chetan Khatri
 
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-Airflow
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-AirflowPyconZA19-Distributed-workloads-challenges-with-PySpark-and-Airflow
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-Airflow
Chetan Khatri
 
ScalaTo July 2019 - No more struggles with Apache Spark workloads in production
ScalaTo July 2019 - No more struggles with Apache Spark workloads in productionScalaTo July 2019 - No more struggles with Apache Spark workloads in production
ScalaTo July 2019 - No more struggles with Apache Spark workloads in production
Chetan Khatri
 
No more struggles with Apache Spark workloads in production
No more struggles with Apache Spark workloads in productionNo more struggles with Apache Spark workloads in production
No more struggles with Apache Spark workloads in production
Chetan Khatri
 
PyConLT19-No_more_struggles_with_Apache_Spark_(PySpark)_workloads_in_production
PyConLT19-No_more_struggles_with_Apache_Spark_(PySpark)_workloads_in_productionPyConLT19-No_more_struggles_with_Apache_Spark_(PySpark)_workloads_in_production
PyConLT19-No_more_struggles_with_Apache_Spark_(PySpark)_workloads_in_production
Chetan Khatri
 
Automate ml workflow_transmogrif_ai-_chetan_khatri_berlin-scala
Automate ml workflow_transmogrif_ai-_chetan_khatri_berlin-scalaAutomate ml workflow_transmogrif_ai-_chetan_khatri_berlin-scala
Automate ml workflow_transmogrif_ai-_chetan_khatri_berlin-scala
Chetan Khatri
 
HBaseConAsia 2018 - Scaling 30 TB's of Data lake with Apache HBase and Scala ...
HBaseConAsia 2018 - Scaling 30 TB's of Data lake with Apache HBase and Scala ...HBaseConAsia 2018 - Scaling 30 TB's of Data lake with Apache HBase and Scala ...
HBaseConAsia 2018 - Scaling 30 TB's of Data lake with Apache HBase and Scala ...
Chetan Khatri
 
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
Chetan Khatri
 
An Introduction to Spark with Scala
An Introduction to Spark with ScalaAn Introduction to Spark with Scala
An Introduction to Spark with Scala
Chetan Khatri
 
HBase with Apache Spark POC Demo
HBase with Apache Spark POC DemoHBase with Apache Spark POC Demo
HBase with Apache Spark POC Demo
Chetan Khatri
 
HKOSCon18 - Chetan Khatri - Open Source AI / ML Technologies and Application ...
HKOSCon18 - Chetan Khatri - Open Source AI / ML Technologies and Application ...HKOSCon18 - Chetan Khatri - Open Source AI / ML Technologies and Application ...
HKOSCon18 - Chetan Khatri - Open Source AI / ML Technologies and Application ...
Chetan Khatri
 
HKOSCon18 - Chetan Khatri - Scaling TB's of Data with Apache Spark and Scala ...
HKOSCon18 - Chetan Khatri - Scaling TB's of Data with Apache Spark and Scala ...HKOSCon18 - Chetan Khatri - Scaling TB's of Data with Apache Spark and Scala ...
HKOSCon18 - Chetan Khatri - Scaling TB's of Data with Apache Spark and Scala ...
Chetan Khatri
 
Fossasia 2018-chetan-khatri
Fossasia 2018-chetan-khatriFossasia 2018-chetan-khatri
Fossasia 2018-chetan-khatri
Chetan Khatri
 
Fossasia ai-ml technologies and application for product development-chetan kh...
Fossasia ai-ml technologies and application for product development-chetan kh...Fossasia ai-ml technologies and application for product development-chetan kh...
Fossasia ai-ml technologies and application for product development-chetan kh...
Chetan Khatri
 
Introduction to Computer Science
Introduction to Computer ScienceIntroduction to Computer Science
Introduction to Computer Science
Chetan Khatri
 
An introduction to Git with Atlassian Suite
An introduction to Git with Atlassian SuiteAn introduction to Git with Atlassian Suite
An introduction to Git with Atlassian Suite
Chetan Khatri
 
Think machine-learning-with-scikit-learn-chetan
Think machine-learning-with-scikit-learn-chetanThink machine-learning-with-scikit-learn-chetan
Think machine-learning-with-scikit-learn-chetan
Chetan Khatri
 
A step towards machine learning at accionlabs
A step towards machine learning at accionlabsA step towards machine learning at accionlabs
A step towards machine learning at accionlabs
Chetan Khatri
 
Voltage measurement using arduino
Voltage measurement using arduinoVoltage measurement using arduino
Voltage measurement using arduino
Chetan Khatri
 

More from Chetan Khatri (20)

Data Science for Beginner by Chetan Khatri and Deptt. of Computer Science, Ka...
Data Science for Beginner by Chetan Khatri and Deptt. of Computer Science, Ka...Data Science for Beginner by Chetan Khatri and Deptt. of Computer Science, Ka...
Data Science for Beginner by Chetan Khatri and Deptt. of Computer Science, Ka...
 
Demystify Information Security & Threats for Data-Driven Platforms With Cheta...
Demystify Information Security & Threats for Data-Driven Platforms With Cheta...Demystify Information Security & Threats for Data-Driven Platforms With Cheta...
Demystify Information Security & Threats for Data-Driven Platforms With Cheta...
 
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-Airflow
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-AirflowPyconZA19-Distributed-workloads-challenges-with-PySpark-and-Airflow
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-Airflow
 
ScalaTo July 2019 - No more struggles with Apache Spark workloads in production
ScalaTo July 2019 - No more struggles with Apache Spark workloads in productionScalaTo July 2019 - No more struggles with Apache Spark workloads in production
ScalaTo July 2019 - No more struggles with Apache Spark workloads in production
 
No more struggles with Apache Spark workloads in production
No more struggles with Apache Spark workloads in productionNo more struggles with Apache Spark workloads in production
No more struggles with Apache Spark workloads in production
 
PyConLT19-No_more_struggles_with_Apache_Spark_(PySpark)_workloads_in_production
PyConLT19-No_more_struggles_with_Apache_Spark_(PySpark)_workloads_in_productionPyConLT19-No_more_struggles_with_Apache_Spark_(PySpark)_workloads_in_production
PyConLT19-No_more_struggles_with_Apache_Spark_(PySpark)_workloads_in_production
 
Automate ml workflow_transmogrif_ai-_chetan_khatri_berlin-scala
Automate ml workflow_transmogrif_ai-_chetan_khatri_berlin-scalaAutomate ml workflow_transmogrif_ai-_chetan_khatri_berlin-scala
Automate ml workflow_transmogrif_ai-_chetan_khatri_berlin-scala
 
HBaseConAsia 2018 - Scaling 30 TB's of Data lake with Apache HBase and Scala ...
HBaseConAsia 2018 - Scaling 30 TB's of Data lake with Apache HBase and Scala ...HBaseConAsia 2018 - Scaling 30 TB's of Data lake with Apache HBase and Scala ...
HBaseConAsia 2018 - Scaling 30 TB's of Data lake with Apache HBase and Scala ...
 
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
TransmogrifAI - Automate Machine Learning Workflow with the power of Scala an...
 
An Introduction to Spark with Scala
An Introduction to Spark with ScalaAn Introduction to Spark with Scala
An Introduction to Spark with Scala
 
HBase with Apache Spark POC Demo
HBase with Apache Spark POC DemoHBase with Apache Spark POC Demo
HBase with Apache Spark POC Demo
 
HKOSCon18 - Chetan Khatri - Open Source AI / ML Technologies and Application ...
HKOSCon18 - Chetan Khatri - Open Source AI / ML Technologies and Application ...HKOSCon18 - Chetan Khatri - Open Source AI / ML Technologies and Application ...
HKOSCon18 - Chetan Khatri - Open Source AI / ML Technologies and Application ...
 
HKOSCon18 - Chetan Khatri - Scaling TB's of Data with Apache Spark and Scala ...
HKOSCon18 - Chetan Khatri - Scaling TB's of Data with Apache Spark and Scala ...HKOSCon18 - Chetan Khatri - Scaling TB's of Data with Apache Spark and Scala ...
HKOSCon18 - Chetan Khatri - Scaling TB's of Data with Apache Spark and Scala ...
 
Fossasia 2018-chetan-khatri
Fossasia 2018-chetan-khatriFossasia 2018-chetan-khatri
Fossasia 2018-chetan-khatri
 
Fossasia ai-ml technologies and application for product development-chetan kh...
Fossasia ai-ml technologies and application for product development-chetan kh...Fossasia ai-ml technologies and application for product development-chetan kh...
Fossasia ai-ml technologies and application for product development-chetan kh...
 
Introduction to Computer Science
Introduction to Computer ScienceIntroduction to Computer Science
Introduction to Computer Science
 
An introduction to Git with Atlassian Suite
An introduction to Git with Atlassian SuiteAn introduction to Git with Atlassian Suite
An introduction to Git with Atlassian Suite
 
Think machine-learning-with-scikit-learn-chetan
Think machine-learning-with-scikit-learn-chetanThink machine-learning-with-scikit-learn-chetan
Think machine-learning-with-scikit-learn-chetan
 
A step towards machine learning at accionlabs
A step towards machine learning at accionlabsA step towards machine learning at accionlabs
A step towards machine learning at accionlabs
 
Voltage measurement using arduino
Voltage measurement using arduinoVoltage measurement using arduino
Voltage measurement using arduino
 

Recently uploaded

space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 

Recently uploaded (20)

space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 

An Introduction Linear Algebra for Neural Networks and Deep learning

  • 1. Talk: Hack Linear Algebra with Python for Deep Neural Network Speaker: Chetan Khatri, Department of Computer Science, University of Kachchh alumnus. Lead - Technology, Accionlabs Inc. In [1]: from IPython.display import Image In [2]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 14-24-40.png") In [3]: Image(filename="/home/chetan/Downloads/screenshot-towardsdatascience.com-2018-01 -13-07-49-05-835.png") common linear algebra operations used in Neural Network Out[2]: Out[3]:
  • 2. Say What ? Linear Algebra for Neural Network In the context of deep learning / Neural network, linear algebra is a mathematical toolbox that offers helpful techniques for manipulating groups of numbers simultaneously. It provides structures like vectors and matrices (spreadsheets) to hold these numbers and new rules for how to add, subtract, multiply, and divide them. Why is it useful? It turns complicated problems into simple, intuitive, efficiently calculated problems. Here is an example of how linear algebra can achieve greater speed and simplicity. In [4]: import numpy as np In [5]: # Multiply two arrays x = [1,2,3] y = [2,3,4] product = [] for i in range(len(x)): product.append(x[i]*y[i]) print product In [6]: # Linear algebra version x = np.array([1,2,3]) y = np.array([2,3,4]) x * y After initializing the arrays, the linear algebra approach was 3x faster. How is it used in Artificial Neural Network / deep learning ? Neural networks store weights in matrices. Linear algebra makes matrix operations fast and easy, especially when training on GPUs. In fact, GPUs were created with vector and matrix operations in mind. Similar to how images can be represented as arrays of pixels, video games generate compelling gaming experiences using enormous, constantly evolving matrices. Instead of processing pixels one-by-one, GPUs manipulate entire matrices of pixels in parallel. Vectors [2, 6, 12] Out[6]: array([ 2, 6, 12])
  • 3. Vectors are 1-dimensional arrays of numbers or terms. In geometry, vectors store the magnitude and direction of a potential change to a point. The vector [3, -2] says go right 3 and down 2. A vector with more than one dimension is called a matrix. Vector -> is arrow pointing in a space. What defines a vector: length and direction it's pointing, as long as length and direction are same you can move all around. Vectors in geometry In [7]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 14-36-32.png") Out[7]:
  • 4. In [8]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 14-36-36.png") In [9]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 14-36-42.png") Out[8]: Out[9]:
  • 5. In [10]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 14-39-55.png") In [11]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-39-53.png") Vector lives in flat plane is 2 dimensional. Out[10]: Out[11]:
  • 6. In [12]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-41-09.png") If vector sits in broader space where you and I leave they are 3 Dimensional. In [13]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-46-00.png") vector addition & vector multiplication plays important role in linear algebra positive numbers indicating rightward and upward motion negative numbers indicating leftward and downward motion Out[12]: Out[13]:
  • 7. Every pair of number gives 1 and only 1 vector. And every vector is associated with 1 and only 1 pair of number. 3 Dimensions - Z Z - Parpendicular to both X & Y axis, which orders triplet numbers. [2 1 3] Move along to how far to X axis. How far to move parellel to Y axis. How far to move parellel to Z axis In Brief: Vectors typically represent movement from a point. They store both the magnitude and direction of potential changes to a point. The vector [-2,5] says move left 2 units and up 5 units. A vector can be applied to any point in space. The vector’s direction equals the slope of the hypotenuse created moving up 5 and left 2. Its magnitude equals the length of the hypotenuse. What's going on to space & Ask computer to figure it out numerically. Scalar operations Scalar operations involve a vector and a number. You modify the vector in-place by adding, subtracting, or multiplying the number from all the values in the vector. Examples: Streaching vector by scalar, Scaling Vector by scalar, Squash in vector by Scalar, Shear vector in plane geometry In [14]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-51-02.png") Out[14]:
  • 8. In [15]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-52-30.png") In [16]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-52-33.png") Out[15]: Out[16]:
  • 9. In [17]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-52-40.png") In [18]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-52-41.png") Out[17]: Out[18]:
  • 10. In [19]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-53-00.png") In [20]: Image(filename="/home/chetan/Pictures/Screenshot from 2018-01-12 15-53-17.png") Span: What does the span of two 3d vectors look like ? All possible linear combination of two vectors. If one vector is already span of other then it's called "Linearly dependent" for some values of a and b. Each vector adds another dimension to span that's "Linearly independent" w /= av for all values of a. Out[19]: Out[20]:
  • 11. Basis The basis of a vector space is a set of linearly independent vectors that span the full space. The word "transformation" suggests that you think using "Movement" Transformation is linear: If all lines must remain lines, origin remains fixed. Not linear: Some lines get curved, grid lines remain parellel and evenly spaced. Elementwise operations In [21]: Image(filename="/home/chetan/Music/images/1_g7cc0GkA7xrkhoh-__Ok3g.png") In elementwise operations like addition, subtraction, and division, values that correspond positionally are combined to produce a new vector. The 1st value in vector A is paired with the 1st value in vector B. The 2nd value is paired with the 2nd, and so on. This means the vectors must have equal dimensions to complete the operation.* In [22]: Image(filename="/home/chetan/Music/images/2.png") In [23]: y = np.array([1,2,3]) x = np.array([2,3,4]) In [24]: y + x Out[21]: Out[22]: Out[24]: array([3, 5, 7])
  • 12. In [25]: y - x In [26]: y / x Vector multiplication There are two types of vector multiplication: Dot product and Hadamard product. Dot product The dot product of two vectors is a scalar. Dot product of vectors and matrices (matrix multiplication) is one of the most important operations in deep learning. In [27]: Image(filename="/home/chetan/Music/images/3.png") In [28]: y = np.array([1,2,3]) x = np.array([2,3,4]) In [29]: np.dot(y,x) Hadamard product Hadamard Product is elementwise multiplication and it outputs a vector. Out[25]: array([-1, -1, -1]) Out[26]: array([0, 0, 0]) Out[27]: Out[29]: 20
  • 13. In [30]: Image(filename="/home/chetan/Music/images/4.png") In [31]: y = np.array([1,2,3]) x = np.array([2,3,4]) In [32]: y * x Vector fields A vector field shows how far the point (x,y) would hypothetically move if we applied a vector function to it like addition or multiplication. Given a point in space, a vector field shows the power and direction of our proposed change at a variety of points in a graph. In [33]: Image(filename="/home/chetan/Music/images/5.png") Matrices A matrix is a rectangular grid of numbers or terms (like an Excel spreadsheet) with special rules for addition, subtraction, and multiplication. Out[30]: Out[32]: array([ 2, 6, 12]) Out[33]:
  • 14. Matrix dimensions We describe the dimensions of a matrix in terms of rows by columns. In [34]: Image(filename="/home/chetan/Music/images/6.png") In [35]: a = np.array([ [1,2,3], [4,5,6] ]) In [36]: a.shape In [37]: b = np.array([ [1,2,3] ]) In [38]: b.shape Matrix scalar operations Scalar operations with matrices work the same way as they do for vectors. Simply apply the scalar to every element in the matrix—add, subtract, divide, multiply, etc. Out[34]: Out[36]: (2, 3) Out[38]: (1, 3)
  • 15. In [39]: Image(filename="/home/chetan/Music/images/7.png") In [40]: a = np.array( [[1,2], [3,4]]) In [41]: a + 1 Matrix elementwise operations In order to add, subtract, or divide two matrices they must have equal dimensions.* We combine corresponding values in an elementwise fashion to produce a new matrix. In [42]: Image(filename="/home/chetan/Music/images/8.png") In [43]: a = np.array([ [1,2], [3,4] ]) b = np.array([ [1,2], [3,4] ]) Out[39]: Out[41]: array([[2, 3], [4, 5]]) Out[42]:
  • 16. In [44]: a + b In [45]: a - b Numpy broadcasting* In numpy the dimension requirements for elementwise operations are relaxed via a mechanism called broadcasting. Two matrices are compatible if the corresponding dimensions in each matrix (rows vs rows, columns vs columns) meet the following requirements: 1. The dimensions are equal, or 2. One dimension is of size 1 In [46]: a = np.array([ [1], [2] ]) b = np.array([ [3,4], [5,6] ]) c = np.array([ [1,2] ]) In [47]: # Same no. of rows # Different no. of columns # but a has one column so this works a * b Out[44]: array([[2, 4], [6, 8]]) Out[45]: array([[0, 0], [0, 0]]) Out[47]: array([[ 3, 4], [10, 12]])
  • 17. In [48]: # Same no. of columns # Different no. of rows # but c has one row so this works b * c In [49]: # Different no. of columns # Different no. of rows # but both a and c meet the # size 1 requirement rule a + c Things get weirder in higher dimensions—3D, 4D, but for now we won’t worry about that. Understanding 2D operations is a good start. Matrix Hadamard product Hadamard product of matrices is an elementwise operation. Values that correspond positionally are multiplied to produce a new matrix. In [50]: Image(filename="/home/chetan/Music/images/9.png") Out[48]: array([[ 3, 8], [ 5, 12]]) Out[49]: array([[2, 3], [3, 4]]) Out[50]:
  • 18. In [51]: a = np.array( [[2,3], [2,3]]) b = np.array( [[3,4], [5,6]]) # Uses python's multiply operator a * b In numpy you can take the Hadamard product of a matrix and vector as long as their dimensions meet the requirements of broadcasting. In [52]: Image(filename="/home/chetan/Music/images/10.png") Matrix transpose Neural networks frequently process weights and inputs of different sizes where the dimensions do not meet the requirements of matrix multiplication. Matrix transpose provides a way to “rotate” one of the matrices so that the operation complies with multiplication requirements and can continue. There are two steps to transpose a matrix: Rotate the matrix right 90° Reverse the order of elements in each row (e.g. [a b c] becomes [c b a]) As an example, transpose matrix M into T: Out[51]: array([[ 6, 12], [10, 18]]) Out[52]:
  • 19. In [53]: Image(filename="/home/chetan/Music/images/11.png") In [54]: a = np.array([ [1, 2], [3, 4]]) a.T Matrix multiplication Matrix multiplication specifies a set of rules for multiplying matrices together to produce a new matrix. Rules Not all matrices are eligible for multiplication. In addition, there is a requirement on the dimensions of the resulting matrix output. 1. The number of columns of the 1st matrix must equal the number of rows of the 2nd 2. The product of an M x N matrix and an N x K matrix is an M x K matrix. The new matrix takes the rows of the 1st and columns of the 2nd Steps Matrix multiplication relies on dot product to multiply various combinations of rows and columns. Out[53]: Out[54]: array([[1, 3], [2, 4]])
  • 20. In [57]: Image(filename="/home/chetan/Music/images/12.png") The operation a1 · b1 means we take the dot product of the 1st row in matrix A (1, 7) and the 1st column in matrix B (3, 5). In [58]: Image(filename="/home/chetan/Music/images/13.png") Here’s another way to look at it: In [59]: Image(filename="/home/chetan/Music/images/14.png") Test yourself with these examples Out[57]: Out[58]: Out[59]: