Machine Learning for Signal Processing
Fundamentals of Linear Algebra
Class 2. 3 Sep 2013 Instructor: Bhiksha Raj
3 Sep 2013 11-755/18-797 1
Machine Learning for Signal Processing Fundamentals of Linear - - PowerPoint PPT Presentation
Machine Learning for Signal Processing Fundamentals of Linear Algebra Class 2. 3 Sep 2013 Instructor: Bhiksha Raj 3 Sep 2013 11-755/18-797 1 Administrivia Change of classroom: BH A51 Being broadcast to west coast Registration:
3 Sep 2013 11-755/18-797 1
3 Sep 2013 11-755/18-797 2
3 Sep 2013 11-755/18-797 3
– Appears repeatedly in the form of Eigen analysis, SVD, Factor analysis – Appears through various properties of matrices that are used in machine learning, particularly when applied to images and sound
– Very small subset of all that’s used – Important subset, intended to help you recollect
3 Sep 2013 11-755/18-797 4
3 Sep 2013 11-755/18-797 5
for i=1:n for j=1:m c(i)=c(i)+y(j)*x(i)*a(i,j) end end C=x*A*y
i
j
T
3 Sep 2013 11-755/18-797 6
Rotation + Projection + Scaling + Perspective
Time Frequency
From Bach’s Fugue in Gm Decomposition (NMF)
– a = 2, a = 3.14, a = -1000, etc.
3 Sep 2013 11-755/18-797 7
attributes
– X, Y, Z coordinates
– Earnings, losses, suicides
– A location in Manhattan
– A sound can be a vector, a series of daily temperatures can be a vector, etc …
3 Sep 2013 11-755/18-797 8 [-2.5av 6st] [2av 4st] [1av 8st]
c a b c , r a b c
, s
– Examples: [3 4 5], [a b c d], .. – [3 4 5] != [4 3 5] Order is important
N-dimensional space
3 Sep 2013 11-755/18-797 9
x z y 3 4 5 (3,4,5) (4,3,5)
– Images can be a matrix, collections of sounds can be a matrix, etc. – A matrix can be vertical stacking of row vectors – Or a horizontal arrangement of column vectors
3 Sep 2013 11-755/18-797 10
S a b c d , R a b c d e f , M f e d c b a R f e d c b a R
– c = 3x1 matrix: 3 rows and 1 column – r = 1x3 matrix: 1 row and 3 columns – S = 2 x 2 matrix – R = 2 x 3 matrix – Pacman = 321 x 399 matrix
3 Sep 2013 11-755/18-797 11
c b a c b a r c ,
f e d c b a d c b a R S ,
– Row and Column = position
– Triples of x,y and value
– “Unraveling” the matrix
– Representations 2 and 4 are equivalent
3 Sep 2013 11-755/18-797 12
1 . 1 . . 1 . 1 1 10 . 10 . 6 5 . 1 . 2 1 10 . 2 . 2 2 . 2 . 1 1
1 . . . 1 1 . 1 1
Y X v Values only; X and Y are implicit
– Properties of matrices are average properties of the traveller’s path to the vector destinations
3 Sep 2013 11-755/18-797 13
3 4 5 (3,4,5)
3 Sep 2013 11-755/18-797 14
1
1
1 b 1
1
1
1 b 1
11
12
11
12
11 b 11
12 b 12
3 Sep 2013 11-755/18-797 15
3 4 5 (3,4,5) 3
(3,-2,-3) (6,2,2)
3 Sep 2013 11-755/18-797 16
1 . . . 1 1 . 1 1 1 . 1 . . 1 . 1 1 10 . 10 . 6 5 . 1 . 2 1 10 . 2 . 2 2 . 2 . 1 1 1 . 1 . . 1 . 1 1 10 . 10 . 6 5 . 1 . 2 1 10 . 2 . 2 2 . 2 . 1 1
+ + Random(3,columns(M))
– Represented as
– As the crow flies – Assuming Euclidean Geometry
3 Sep 2013 11-755/18-797 17 [-2av 17st] [-6av 10st]
a b ...
a2 b2 ...2
3 4 5 (3,4,5) Length = sqrt(32 + 42 + 52)
3 Sep 2013 11-755/18-797 18
– Vectors must have the same number of elements – Row vector times column vector = scalar
– Column vector times row vector = matrix
3 Sep 2013 11-755/18-797 19
a b c d e f
a d ae a f b d be b f c d c e c f
a b c
d e f a d be c f
– Coordinates are yards, not ave/st
– a = [200 1600], b = [770 300]
relates to the length of a projection
– How much of the first vector have we covered by following the second one? – Must normalize by the length of the “target” vector
3 Sep 2013 11-755/18-797 20 [200yd 1600yd] norm ≈ 1612 [770yd 300yd] norm ≈ 826
a bT a 200 1600
300 200 1600
393yd
norm ≈ 393yd
– Energy at a discrete set of frequencies – Actually 1 x 4096 – X axis is the index of the number in the vector
– Y axis is the value of the number in the vector
3 Sep 2013 11-755/18-797 21
frequency Sqrt(energy) frequency frequency
1 . . . 1 54 . 9 11
1 . 14 . 16 . . 24 . 3
. 13 . 3 . .
C E C2
– How much can you fake a C by playing an E – C.E / |C||E| = 0.1 – Not very much
– C.C2 / |C| /|C2| = 0.5 – Not bad, you can fake it
3 Sep 2013 11-755/18-797 22
frequency Sqrt(energy) frequency frequency
1 . . . 1 54 . 9 11
1 . 14 . 16 . . 24 . 3
. 13 . 3 . .
C E C2
– Shows how the energy in each frequency varies with time – The pattern in each column is a scaled version of the spectrum – Each row is a scaled version of the modulation
3 Sep 2013 11-755/18-797 23
3 Sep 2013 11-755/18-797 24
2 1 2 1
3 Sep 2013 11-755/18-797 25
2 1 2 1
3 Sep 2013 11-755/18-797 26
6 . 1 3 . 1 7 . 3 . Y
– X axis = normal to the second row vector
3 Sep 2013 11-755/18-797 27
6 . 1 3 . 1 7 . 3 . Y
by the 1..k-1,k+1..N-th row vectors in the matrix
– Any set of K-1 vectors represent a hyperplane of dimension K-1 or less
the k-th row vector
– Expressed in inverse-lengths of the vector
3 Sep 2013 11-755/18-797 28
3 Sep 2013 11-755/18-797 29
3 Sep 2013 11-755/18-797 30
– The three column vectors of the matrix X are the spectra of three notes – The multiplying column vector Y is just a mixing vector – The result is a sound that is the mixture of the three notes
3 Sep 2013 11-755/18-797 31
X
Y
– The images are arranged as columns
– The result of the multiplication is rearranged as an image
3 Sep 2013 11-755/18-797 32
200 x 200 200 x 200 200 x 200 40000 x 2
40000 x 1 2 x 1
the number of columns from the second matrix
3 Sep 2013 11-755/18-797 33
A B a1 a2 b1 b2 a1 b1 a1 b2 a2 b1 a2 b2
3 Sep 2013 11-755/18-797 34
NK N MN N K M K M NK N NK MN M N N
b b a a b b a a b b a a b b b b a a a a a a . . . ... . . . . . . . . . . . . . . . . . . . . .
1 1 2 21 2 12 1 11 1 11 1 11 1 2 21 1 11
The outer product of the first column of A and the first row of
Sum of outer products
3 Sep 2013 11-755/18-797 35
1 . . . 24 9 . . 3 1
X
. . . . . 1 95 . 9 . 8 . 7 . 6 . 5 . . . . . . . 5 . 5 . 7 . 9 . 1 . . . . . 5 . 75 . 1 75 . 5 .
Y
3 Sep 2013 11-755/18-797 36
1 . . . 24 9 . . 3 1
X
. . . . . 1 95 . 9 . 8 . 7 . 6 . 5 . . . . . . . 5 . 5 . 7 . 9 . 1 . . . . . 5 . 75 . 1 75 . 5 .
Y
3 Sep 2013 11-755/18-797 37
1 . . . 24 9 . . 3 1
X
. . . . . 1 95 . 9 . 8 . 7 . 6 . 5 . . . . . . . 5 . 5 . 7 . 9 . 1 . . . . . 5 . 75 . 1 75 . 5 .
Y
3 Sep 2013 11-755/18-797 38
. . . . . 1 95 . 9 . 8 . 7 . 6 . 5 . . . . . . . 5 . 5 . 7 . 9 . 1 . . . . . 5 . 75 . 1 75 . 5 .
1 . . . 24 9 . . 3 1
X
3 Sep 2013 11-755/18-797 39
. . . . . 1 95 . 9 . 8 . 7 . 6 . 5 . . . . . . . 5 . 5 . 7 . 9 . 1 . . . . . 5 . 75 . 1 75 . 5 .
1 . . . 24 9 . . 3 1
X
3 Sep 2013 11-755/18-797 40
3 Sep 2013 11-755/18-797 41
. . . . . .
2 2 1 1
j i j i
1 9 . 8 . 7 . 6 . 5 . 4 . 3 . 2 . 1 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 1
– The columns represent a sequence of images of decreasing intensity
3 Sep 2013 11-755/18-797 42
1 9 . 8 . 7 . 6 . 5 . 4 . 3 . 2 . 1 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 1
. . . . . .
2 2 1 1
j i j i
. . . . . . 8 . 9 . . . . . . . . . . . . . . . . . . . . . . . . . . 8 . 9 . . . . . . . 8 . 9 .
2 2 2 1 1 1 N N N
i i i i i i i i i
3 Sep 2013 11-755/18-797 43
1 9 . 8 . 7 . 6 . 5 . 4 . 3 . 2 . 1 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 1
. . . . . .
2 2 1 1
j i j i
3 Sep 2013 11-755/18-797 44
. . . . . .
2 2 1 1
j i j i
1 9 . 8 . 7 . 6 . 5 . 4 . 3 . 2 . 1 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 1
– All diagonal elements are 1.0 – All off-diagonal elements are 0.0
3 Sep 2013 11-755/18-797 45
1 1 Y
– May flip axes
3 Sep 2013 11-755/18-797 46
1 2 Y
3 Sep 2013 11-755/18-797 47
1 . 1 . . 1 . 1 1 10 . 10 . 6 5 . 1 . 2 1 10 . 2 . 2 2 . 2 . 1 1 1 1 2
– The Y axis and pixel value are scaled by identity
3 Sep 2013 11-755/18-797 48
) 2 x ( Newpic . . . . . . . 5 . . 5 . 1 5 . . 5 . 1 N N EA A
3 Sep 2013 11-755/18-797 49
D =
1 2 1 P Newpic B G R P
3 Sep 2013 11-755/18-797 50
– The row entries are axis vectors in a different order – The result is a combination of rotations and reflections
3 Sep 2013 11-755/18-797 51
3 4 5 (3,4,5) X Y Z 4 5 3 X (old Y) Y (old Z) Z (old X)
3 Sep 2013 11-755/18-797 52
1 1 1 P 1 1 1 P
1 . 1 . . 1 . 1 1 10 . 10 . 6 5 . 1 . 2 1 10 . 2 . 2 2 . 2 . 1 1
– Object represented as a matrix of 3-Dimensional “position” vectors – Positions identify each point on the surface
3 Sep 2013 11-755/18-797 53
1 1 1 P 1 1 1 P
N N N
z z z y y y x x x . . . . . .
2 1 2 1 2 1
– The new axes are at an angle q to the old one
3 Sep 2013 11-755/18-797 54
' ' cos sin sin cos y x X y x X
new
q q q q
q
R
X Y (x,y)
new
q
X Y (x,y) (x’,y’)
x’ x y’ y q
– Rotation only applies on the “coordinate” rows – The value does not change – Why is pacman grainy?
3 Sep 2013 11-755/18-797 55
1 . 1 . . 1 . 1 1 . . 10 . 6 5 . 1 . 2 1 . . 2 . 2 2 . 2 . 1 1 1 45 cos 45 sin 45 sin 45 cos R 1 . 1 . . 1 . 1 1 . . 2 12 . 2 8 2 7 . 2 3 . 2 3 2 . . 2 8 . 2 4 2 3 . 2 . 2
3 Sep 2013 11-755/18-797 56
X Y Z q Xnew Ynew Znew a
3 Sep 2013 11-755/18-797 57
looked at it from above the plane shown by the grid?
– Normal to the plane – Answer: the figure to the right
3 Sep 2013 11-755/18-797 58
– Or matrix [W1 W2 ..] – Any vector can be projected onto this plane – The matrix A that rotates and scales the vector so that it becomes its projection is a projection matrix
3 Sep 2013 11-755/18-797 59
90degrees projection W1 W2
– P = W (WTW)-1 WT
will give you the same projection matrix
– P = V (VTV)-1 VT
3 Sep 2013 11-755/18-797 60
90degrees projection W1 W2
3 Sep 2013 11-755/18-797 61
– ANY two so long as they have different angles
– I’m missing a step here – what is it?
3 Sep 2013 11-755/18-797 62
the plane in 3D
– The result of the projection is a 3-D vector – P = W (WTW)-1 WT = 3x3, P*Vector = 3x1 – The image must be rotated till the plane is in the plane of the paper
3 Sep 2013 11-755/18-797 63
– Px = x if x is on the plane – If the object is already on the plane, there is no further projection to be performed
– P (Px) = Px – That is because Px is already on the plane
– P2 = P
64 3 Sep 2013 11-755/18-797
– We often cannot do so – But we can explain a significant portion of it
– In our previous example, the “data” were all the points on a cone, and the bases were vectors on the plane
3 Sep 2013 11-755/18-797 65
3 Sep 2013 11-755/18-797 66
How much of the above music was composed of the
I.e. how much can it be explained by the notes
3 Sep 2013 11-755/18-797 67
M = spectrogram; W = note P = W (WTW)-1 WT Projected Spectrogram = P * M
M = W =
3 Sep 2013 11-755/18-797 68
Floored all matrix values below a threshold to zero
M = W =
3 Sep 2013 11-755/18-797 69
P = W (WTW)-1 WT Projected Spectrogram = P * M
M = W =
3 Sep 2013 11-755/18-797 70
P = W (WTW)-1 WT Projected Spectrogram = P * M
M = W =
– Approximation: Vapprox = a*note1 + b*note2 + c*note3.. – Error vector E = V – Vapprox – Squared error energy for V e(V) = norm(E)2 – Total error = sum over all V { e(V) } = SV e(V)
– It does not give you “a”, “b”, “c”.. Though
3 Sep 2013 11-755/18-797 71
c b a Vapprox
note1 note2 note3
glass window
projection on the window merge at a common point
– The eye – As a result, parallel lines in the scene apparently merge to a point
3 Sep 2013 11-755/18-797 72
– Top Left: One-point perspective – Top Right: Two-point perspective – Right: Three-point perspective
3 Sep 2013 11-755/18-797 73
3 Sep 2013 11-755/18-797 74
window from eye), and (x’,y’,z’) (location being projected)
3 Sep 2013 11-755/18-797 75
' z z ' y y ' x x
Property of a line through origin
' y y ' x x ' z z a a a
X Y x,y z x’,y’,z’
– Using yellow window as reference: – (x,y) = (x,y,1) – (x’,y’) = (x,y,c’) c’ = a’/a – Locations on line generally represented as (x,y,c)
3 Sep 2013 11-755/18-797 76
X Y x,y x’,y’
' x ' x a a ' y ' y a a ' x x ' a a ' x x ' a a ' y y ' a a
– (X,Y,Z,c) – “c” is the “scaling” factor that represents the distance of the actual scene
– Xactual = X/c, Yactual = Y/c, Zactual = Z/c
3 Sep 2013 11-755/18-797 77
x1’,y1’,z1’ x2’,y2’,z2’ x2,y2,z2 x1,y1,z1
' x ' x
1 1
a a ' y ' y
1 1
a a ' z ' z
1 1
a a ' x ' x
2 2
a a ' y ' y
2 2
a a ' z ' z
2 2
a a
– In 2D the plane in which all points have values (x,y,1)
3 Sep 2013 11-755/18-797 78