Machine Learning for Signal Processing Fundamentals of Linear Algebra Class 2. 6 Sep 2016 Instructor: Bhiksha Raj 11-755/18-797 1
Overview • Vectors and matrices • Basic vector/matrix operations • Various matrix types • Projections 11-755/18-797 2
Book • Fundamentals of Linear Algebra, Gilbert Strang • Important to be very comfortable with linear algebra – Appears repeatedly in the form of Eigen analysis, SVD, Factor analysis – Appears through various properties of matrices that are used in machine learning – Often used in the processing of data of various kinds – Will use sound and images as examples • Today ’ s lecture: Definitions – Very small subset of all that ’ s used – Important subset, intended to help you recollect 11-755/18-797 3
Incentive to use linear algebra • Simplified notation! y j x i a ij T x A y j i • Easier intuition – Really convenient geometric interpretations • Easy code translation! for i=1:n for j=1:m C=x*A*y c(i)=c(i)+y(j)*x(i)*a(i,j) end end 11-755/18-797 4
And other things you can do From Bach’s Fugue in Gm Frequency Rotation + Projection + Time Decomposition (NMF) Scaling + Perspective • Manipulate Data • Extract information from data • Represent data.. • Etc. 11-755/18-797 5
Scalars, vectors, matrices, … • A scalar a is a number – a = 2, a = 3.14, a = -1000, etc. • A vector a is a linear arrangement of a collection of scalars , a 3.14 a 1 2 3 32 • A matrix A is a rectangular arrangement of a collection of scalars 1 2 . 2 6 A 3 . 1 1 5 11-755/18-797 6
Vectors in the abstract • Ordered collection of numbers – Examples: [3 4 5], [a b c d], .. – [3 4 5] != [4 3 5] Order is important • Typically viewed as identifying ( the path from origin to ) a location in an N-dimensional space (3,4,5) 5 (4,3,5) 3 z y 4 x 11-755/18-797 7
Vectors in reality • Vectors usually hold sets of numerical attributes – X, Y, Z coordinates [-2.5av 6st] [1av 8st] • [1, 2, 0] – [height(cm) weight(kg)] – [175 72] – A location in Manhattan • [3av 33st] • A series of daily temperatures [2av 4st] • Samples in an audio signal • Etc. 11-755/18-797 8
Vector norm (3,4,5) Length = sqrt(3 2 + 4 2 + 5 2 ) • Measure of how long a 5 vector is: – Represented as x a 2 b 2 ... 2 a b ... 4 • Geometrically the shortest 3 distance to travel from the [-2av 17st] [-6av 10st] origin to the destination – As the crow flies – Assuming Euclidean Geometry 11-755/18-797 9
Vector Operations: Multiplication by scalar (7.5, 10, 12.5) Multiplication by scalar (3,4,5) “ stretches ” the vector 3 • Vector multiplication by scalar: each component multiplied by scalar – 2.5 x (3,4,5) = (7.5, 10, 12.5) • Note: as a result, vector norm is also multiplied by the scalar – ||2.5 x (3,4,5)|| = 2.5x|| (3, 4, 5)|| 11-755/18-797 10
Vector Operations: Addition 3 (3,4,5) -2 5 (3,-2,-3) -3 4 (6,2,2) 3 • Vector addition: individual components add – (3,4,5) + (3,-2,-3) = (6,2,2) – Only applicable if both vectors are the same size 11-755/18-797 11
An introduction to spaces • Conventional notion of “ space ” : a geometric construct of a certain number of “ dimensions ” – E.g. the 3-D space that this room and every object in it lives in 11-755/18-797 12
A vector space • A vector space is an infinitely large set of vectors the following properties – The set includes the zero vector (of all zeros) – The set is “ closed ” under addition • If X and Y are in the set, aX + bY is also in the set for any two scalars a and b – For every X in the set, the set also includes the additive inverse Y = -X , such that X + Y = 0 11-755/18-797 13
Additional Properties • Additional requirements: – Scalar multiplicative identity element exists: 1X = X – Addition is associative: X + Y = Y + X – Addition is commutative: (X+Y)+Z = X+(Y+Z) – Scalar multiplication is commutative: a(bX) = (ab) X – Scalar multiplication is distributive: (a+b)X = aX + bX a(X+Y) = aX + aY 11-755/18-797 14
Example of vector space • Set of all three-component column vectors – Note we used the term three- component, rather than three- dimensional • The set includes the zero vector • For every X in the set 𝛽 ∈ ℛ , every a X is in the set • For every X, Y in the set, a X + b Y is in the set • - X is in the set • Etc. 11-755/18-797 15
Example: a function space 11-755/18-797 16
Dimension of a space • Every element in the space can be composed of linear combinations of some other elements in the space – For any X in S we can write X = a Y 1 + b Y 2 + c Y 3 .. for some other Y 1 , Y 2 , Y 3 .. in S • Trivial to prove.. 11-755/18-797 17
Dimension of a space • What is the smallest subset of elements that can compose the entire set? – There may be multiple such sets • The elements in this set are called “bases” – The set is a “basis” set • The number of elements in the set is the “dimensionality” of the space 11-755/18-797 18
Dimensions: Example • What is the dimensionality of this vector space 11-755/18-797 19
Dimensions: Example • What is the dimensionality of this vector space? – First confirm this is a proper vector space • Note: all elements in Z are also in S (slide 19) – Z is a subspace of S 11-755/18-797 20
Dimensions: Example • What is the dimensionality of this space? 11-755/18-797 21
Moving on…. 11-755/18-797 22
Interpreting Matrices • Two interpretations of a matrix • As a transform that modifies vectors and vector spaces a b c d • As a container for data (vectors) a b c d e f g h i j k l m n o • In the next two classes we ’ ll focus on the first view • But we will mostly consider the second view for ML algorithms in the our discussions of signal representations 11-755/18-797 23
Interpreting Matrices as collections of vectors • A matrix can be vertical stacking of row vectors a b c R d e f – The space of all vectors that can be composed from the rows of the matrix is the row space of the matrix • Or a horizontal arrangement of column vectors a b c R d e f – The space of all vectors that can be composed from the columns of the matrix is the column space of the matrix 11-755/18-797 24
Dimensions of a matrix • The matrix size is specified by the number of rows and columns a c b , r a b c c – c = 3x1 matrix: 3 rows and 1 column – r = 1x3 matrix: 1 row and 3 columns a b a b c S , R c d d e f – S = 2 x 2 matrix – R = 2 x 3 matrix – Pacman = 321 x 399 matrix 11-755/18-797 25
Representing an image as a matrix • 3 pacmen • A 321 x 399 matrix – Row and Column = position • A 3 x 128079 matrix – Triples of x,y and value • A 1 x 128079 vector – “Unraveling” the matrix 1 1 . 2 . 2 2 . 2 . 10 Y 1 2 . 1 . 5 6 . 10 . 10 X 1 1 . 1 . 0 0 . 1 . 1 v • Note: All of these can be recast as the 1 1 . 1 1 . 0 0 0 . . 1 matrix that forms the image Values only; X and Y are – Representations 2 and 4 are equivalent implicit • The position is not represented 11-755/18-797 26
Basic arithmetic operations • Addition and subtraction (vectors and matrices) – Element-wise operations a 1 b 1 b a b a b a 1 1 1 1 1 1 a b a 2 b 2 a b a 2 b 2 a 2 b 2 a 2 b 2 a 3 b 3 a 3 b 3 a 3 b 3 a 3 b 3 11 b 12 b A B a a b b a a 11 12 11 12 11 12 a 21 b 21 a 22 b 22 a 21 a 22 b 21 b 22 11-755/18-797 27
Recommend
More recommend