Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

HW 1 Solutions New York University CS-GY 9123

Rating
-
Sold
-
Pages
2
Grade
A+
Uploaded on
06-02-2023
Written in
2022/2023

ECE-GY 9123 / Spring 2021 Homework 1 1. Fun with vector calculus. This question has two parts. a. If x is a d-dimensional vector variable, write down the gradient of the function f(x) = kxk 2 2 . b. SUppose we have n data points that are real d-dimensional vectors. Analytically derive a constant vector µ for which Xn i=1 kxi − µk 2 2 is minimized. Solution For part a, you can either write out the explicit form of the squared loss function and take derivatives with respect to each of the d coordinates. The answer should be: ∇f(x) = 2x, or, ∂f ∂x(j) = 2x (j) . For part b, take the derivative of the given expression and set to zero. You can either decouple it into coordinates or take the vector derivative (which resembles the expression you got to part a, except there is a µ), and set to zero: Xn i=1 2(xi − µ) = 0. Solving for µ, the final answer should be: µ = Pn i=1 xi n . 2. Linear regression with non-standard losses. In class we derived an analytical expression for the optimal linear regression model using the least squares loss for a finite dataset. If X is the matrix of training data points (stacked row-wise) and y is the vector of labels, then: a. Using matrix/vector notation, write down a loss function that measures the training error in terms of the `1-norm. b. Can you write down the optimal linear model in closed form? If not, why not? c. If the answer to b is no, can you think of an alternative algorithm to optimize the loss function? Comment on its pros and cons. Solution a. L(w) = kXw − yk

Show more Read less
Institution
Course

Content preview

ECE-GY 9123 / Spring 2021


Homework 1
1. Fun with vector calculus. This question has two parts.
a. If x is a d-dimensional vector variable, write down the gradient of the function f (x) =
kxk22 .
b. SUppose we have n data points that are real d-dimensional vectors. Analytically derive a
constant vector µ for which
Xn
kxi − µk22
i=1

is minimized.
Solution
For part a, you can either write out the explicit form of the squared loss function and take
derivatives with respect to each of the d coordinates. The answer should be:

∂f
∇f (x) = 2x, or, = 2x(j) .
∂x(j)

For part b, take the derivative of the given expression and set to zero. You can either decouple
it into coordinates or take the vector derivative (which resembles the expression you got to part
a, except there is a µ), and set to zero:
n
X
2(xi − µ) = 0.
i=1

Solving for µ, the final answer should be:
Pn
i=1 xi
µ= .
n

2. Linear regression with non-standard losses. In class we derived an analytical expression for
the optimal linear regression model using the least squares loss for a finite dataset. If X is the
matrix of training data points (stacked row-wise) and y is the vector of labels, then:
a. Using matrix/vector notation, write down a loss function that measures the training error
in terms of the `1 -norm.
b. Can you write down the optimal linear model in closed form? If not, why not?
c. If the answer to b is no, can you think of an alternative algorithm to optimize the loss
function? Comment on its pros and cons.
Solution
a. L(w) = kXw − yk1 .



1

Written for

Course

Document information

Uploaded on
February 6, 2023
Number of pages
2
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$5.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ExamsConnoisseur Self
Follow You need to be logged in order to follow users or courses
Sold
587
Member since
3 year
Number of followers
344
Documents
1492
Last sold
2 weeks ago

4.2

68 reviews

5
40
4
11
3
13
2
1
1
3

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions