Q2) Gradient Descent Algorithm (2 marks) i) Consider the last 4 digits of your mobile number (Note : In case there is a

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Q2) Gradient Descent Algorithm (2 marks) i) Consider the last 4 digits of your mobile number (Note : In case there is a

Post by answerhappygod »

Q2) Gradient Descent Algorithm (2 marks)
i) Consider the last 4 digits of your mobile number (Note : In case
there is a 0 in one of the digits replace it by 3). Let it be
n1n2n3n4. Generate a random matrix A of size n1n2 ×n3n4. For
example, if the last four digits are 2311, generate a random
matrix of size 23 ×11. Write a code to calculate the l∞ norm
of this matrix.
Deliverable(s) : The code that generates the results. (0.5)
ii) Generate a random vector b of size n1n2 ×1 and consider the
function
f(x) = 1/2∥Ax −b∥22 where ∥ · ∥2 is the vector ℓ2 norm. Its
gradient is given to be ∇f(x) = A⊤Ax −A⊤b. Write a code to
find the local minima of this function by using the gradient
descent algorithm (by using the gradient expression given
to you). The step size τ in the iteration xk+1 = xk −τ∇f(xk)
should be chosen by the formula
τ = gTk gk/gTk
ATAgk where gk = ∇f(xk) = A⊤Axk −A⊤b. The algorithm
should execute until ∥xk −xk−1∥2 < 10−4.
Deliverable(s) : The code that finds the minimum of the given
function 2 and the expression for τ. The values of xk and
f(xk) should be stored in a file. (1)
iii) Generate the graph of f(xk) vs k where k is the iteration
number and xk is the current estimate of x at iteration k.
This graph should convey the decreasing nature of function
values.
Deliverable(s) : The graph that is generated.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply