 cpollett

Nov 8 In-Class Exercise. - 08/11/2017CS 256 Fall 2017

Post to this thread your solutions to the Nov 8 In-class Exercise.
Best,
Chris
Post to this thread your solutions to the Nov 8 In-class Exercise. Best, Chris rahuldalal

-- Nov 8 In-Class Exercise. - 08/11/2017CS 256 Fall 2017

W' = [[2,0,0], [0,0,-1], [0,3,0]] x = [-1,3,-3]
For OMP -2 number of non zero entries in h is 1
Case 1 : Let h = [c,0,0] || x - W'h|| = (1+2c)^2 + 9 + 9 --> min value . = 18 when c = -1/2
Case 2: || x - W'h|| = (3+3c)^2 + 1 + 9 --> min value . = 10 when c = -1 and h=[0,-1,0]
Case 3: || x - W'h|| = (3+c)^2 + 1 + 9 --> min value . = 10 when c = -3 and h=[0,0,-3]
Both case 2 and case 3 provide the answer

Last Edited: 08/11/2017
W' = [[2,0,0], [0,0,-1], [0,3,0]] x = [-1,3,-3] For OMP -2 number of non zero entries in h is 1 Case 1 : Let h = [c,0,0] || x - W'h|| = (1+2c)^2 + 9 + 9 --> min value . = 18 when c = -1/2 Case 2: || x - W'h|| = (3+3c)^2 + 1 + 9 --> min value . = 10 when c = -1 and h=[0,-1,0] Case 3: || x - W'h|| = (3+c)^2 + 1 + 9 --> min value . = 10 when c = -3 and h=[0,0,-3] Both case 2 and case 3 provide the answer amerrez3

-- Nov 8 In-Class Exercise. - 08/11/2017CS 256 Fall 2017

• assuming h = [0, 0, C]
• W' * h = [ 0, -C, 0]
• X - W'*h = [-1, 3+C, -3]
• argmin = 1+(3+c)^2 + (-3)^2 ==> C = -3
• h = [0, 0, -3]
• we still need to do the two other cases. h=[0,C,0], h=[C,0,0]

Last Edited: 08/11/2017
* assuming h = [0, 0, C] * W' * h = [ 0, -C, 0] * X - W'*h = [-1, 3+C, -3] * argmin = 1+(3+c)^2 + (-3)^2 ==> C = -3 * h = [0, 0, -3] * we still need to do the two other cases. h=[0,C,0], h=[C,0,0] ctmackay

-- Nov 8 In-Class Exercise. - 08/11/2017CS 256 Fall 2017

we have w as a 3x3 matrix, x = 3x1 matrix, h = 3x1 matrix, since k = 2, h can only contain 1 non zero entry.
write the magnitude as a system of equations, distance = ||x - w*h|| solving for h1, h2, h3 we get h1 = -1/2, h2=3, h3=1
evaluate the arrays for each of these h values with the other entries as 0.
import numpy as np
x = np.matrix([[-1], , [-3]])
w = np.matrix([[2, 0, 0], [0, 0, -1], [0, 3, 0]])
print(x)
print(w)
h = np.matrix([[-1 / 2], , ])
distance = np.linalg.norm(x - w * h)
print(distance)
h = np.matrix([, , ])
distance = np.linalg.norm(x - w * h)
print(distance)
h = np.matrix([, , ])
distance = np.linalg.norm(x - w * h)
print(distance)

4.24264068712
12.409673646
5.09901951359
since h1 = -1/2 had the lowest distance, we can use h = [-1/2,0,0]

Last Edited: 08/11/2017
we have w as a 3x3 matrix, x = 3x1 matrix, h = 3x1 matrix, since k = 2, h can only contain 1 non zero entry. write the magnitude as a system of equations, distance = ||x - w*h|| solving for h1, h2, h3 we get h1 = -1/2, h2=3, h3=1 evaluate the arrays for each of these h values with the other entries as 0. import numpy as np x = np.matrix([[-1], , [-3]]) w = np.matrix([[2, 0, 0], [0, 0, -1], [0, 3, 0]]) print(x) print(w) h = np.matrix([[-1 / 2], , ]) distance = np.linalg.norm(x - w * h) print(distance) h = np.matrix([, , ]) distance = np.linalg.norm(x - w * h) print(distance) h = np.matrix([, , ]) distance = np.linalg.norm(x - w * h) print(distance) 4.24264068712 12.409673646 5.09901951359 since h1 = -1/2 had the lowest distance, we can use h = [-1/2,0,0] ishan50492

-- Nov 8 In-Class Exercise. - 08/11/2017CS 256 Fall 2017

Still Working

Last Edited: 08/11/2017
Still Working jason.chee

-- Nov 8 In-Class Exercise. - 08/11/2017CS 256 Fall 2017

W' = [[2,0,0],[0,0,-1],[0,3,0]] x=[[-1],,[-3]]
k=2, h has 1 non-0 entry
x - W' * h
1. h = [c,0,0]
2. h = [0,c,0]
3. h = [0,0,c]

Last Edited: 08/11/2017
W' = [[2,0,0],[0,0,-1],[0,3,0]] x=[[-1],,[-3]] k=2, h has 1 non-0 entry x - W' * h 1. h = [c,0,0] 2. h = [0,c,0] 3. h = [0,0,c] kunalrdeshmukh

-- Nov 8 In-Class Exercise. - 08/11/2017CS 256 Fall 2017

W' = [[2,0,0],[0,0,-1],[0,3,0]] x = [-1,3,-3]
let h = [a, b, c] W'h = [2a, -b, 3c]
W' = [[2,0,0],[0,0,-1],[0,3,0]] x = [-1,3,-3] let h = [a, b, c] W'h = [2a, -b, 3c] avinashpmore

-- Nov 8 In-Class Exercise. - 08/11/2017CS 256 Fall 2017

If we can have X = W'h, then we will have norm to be zero. But, in that case we might not have two out of those 3 entries to be zero.
So finding [h1, h2, h3] which makes X = W'h, i.e. making h = h = [-1/2, -1, -3] and then finding x-W'h for
[h1,0,0] as (1),
[0,h2,0] as (2)
[0,0,h3] as (3)
and comparing (1), (2) and (3) will 3 different values.
taking the h which minimizes ||x- W'h||^2 gives the solution. In our case, (2) and (3) give the result with ||x- W'h||^2 being minimum.
h can be [0, -1, 0] or [0, 0, -3].

Last Edited: 08/11/2017
If we can have X = W'h, then we will have norm to be zero. But, in that case we might not have two out of those 3 entries to be zero. So finding [h1, h2, h3] which makes X = W'h, i.e. making h = h = [-1/2, -1, -3] and then finding x-W'h for [h1,0,0] as (1), [0,h2,0] as (2) [0,0,h3] as (3) and comparing (1), (2) and (3) will 3 different values. taking the h which minimizes ||x- W'h||^2 gives the solution. In our case, (2) and (3) give the result with ||x- W'h||^2 being minimum. h can be [0, -1, 0] or [0, 0, -3]. kushalk

-- Nov 8 In-Class Exercise. - 08/11/2017CS 256 Fall 2017

W’ = [[2,0,0], [0,0,-1], [0,3,0]] x = [-1,3,-3]
For OMP -2 number of non zero entries in h is 1
Case 1 : Let h = [c,0,0] || x - W’h|| = (1+2c)^2 + 9 + 9 --> min value . = 18 when c = -1/2
Case 2: || x - W’h|| = (3+3c)^2 + 1 + 9 --> min value . = 10 when c = -1 and h=[0,-1,0]
Case 3: || x - W’h|| = (3+c)^2 + 1 + 9 --> min value . = 10 when c = -3 and h=[0,0,-3]
Both case 2 and case 3 provide the answer
W’ = [[2,0,0], [0,0,-1], [0,3,0]] x = [-1,3,-3] For OMP -2 number of non zero entries in h is 1 Case 1 : Let h = [c,0,0] || x - W’h|| = (1+2c)^2 + 9 + 9 --> min value . = 18 when c = -1/2 Case 2: || x - W’h|| = (3+3c)^2 + 1 + 9 --> min value . = 10 when c = -1 and h=[0,-1,0] Case 3: || x - W’h|| = (3+c)^2 + 1 + 9 --> min value . = 10 when c = -3 and h=[0,0,-3] Both case 2 and case 3 provide the answer thinh

-- Nov 8 In-Class Exercise. - 08/11/2017CS 256 Fall 2017

((resource:IMG_4387.jpg|Resource Description for IMG_4387.jpg))

[X ]