CS 189/289A, Midterm
Fall 2025
Name:
Email: @berkeley.edu
Student ID:
Room where you’re taking the exam:
Name and SID of the person on your right:
Name and SID of the person on your left:
Instructions:
This exam consists of 69 points spread out over 7 questions and the Honor Code certi-
fication. The exam must be completed in 110 minutes unless you have accommodations
supported by a DSP letter.
Note that you should select one choice for questions with circular bubbles. There is al-
ways at least one correct answer. Please fully shade in the circle to mark your answer.
For all math questions, please simplify your answer. Please also show your work if a
large box is provided. For all coding questions, you may use commas and/or one or more
function calls in each blank.
For all Python questions, you may assume Pandas has been imported as pd, NumPy has
been imported as np, and Plotly Express has been imported as px.
You MUST write your Student ID number at the top of each page.
Honor Code [1 Pt]:
As a member of the UC Berkeley community, I act with honesty, integrity, and respect
for others. I am the person whose name is on the exam, and I completed this exam in
accordance with the Honor Code.
Signature:
1
,CS 189/289A Midterm, Page 2 of 23 SID:
This page has been intentionally left blank.
, CS 189/289A Midterm, Page 3 of 23 SID:
1 Matching the Loss Surface
The following plots depict the error surfaces for several models on different datasets. The contour
plots show the contours of the error surface. Use these plots to answer the questions below.
60
35 50
50
30
40 40
25
30
Error
Error
Error
20 30
15 20 20
10 10 10
5
0 0
−6 −4 −2 0 2 4 6 −6 −4 −2 0 2 4 6 −6 −4 −2 0 2 4 6
w w w
(A) (B) (C)
(D) (E) (F)
(a) [1 Pt] Which of the following most accurately describes the loss surface in Figure (A)?
⃝ This is the loss for a least squares regression problem.
⃝ This is the loss of a linearly separable classification problem.
⃝ Significant L2 regularization is needed for this loss surface.
⃝ This is the loss of the classification problem.
(b) [2 Pts] Which of the above loss functions corresponds to the cross entropy loss for a logistic
regression model of the form y(x) = σ (x × w) where x, w ∈ R with the following data:
⃝ (A)
class 1
⃝ (B)
⃝ (C)
⃝ (D)
label
⃝ (E)
⃝ (F)
class 0
−3 −2 −1 0 1 2 3
x
Fall 2025
Name:
Email: @berkeley.edu
Student ID:
Room where you’re taking the exam:
Name and SID of the person on your right:
Name and SID of the person on your left:
Instructions:
This exam consists of 69 points spread out over 7 questions and the Honor Code certi-
fication. The exam must be completed in 110 minutes unless you have accommodations
supported by a DSP letter.
Note that you should select one choice for questions with circular bubbles. There is al-
ways at least one correct answer. Please fully shade in the circle to mark your answer.
For all math questions, please simplify your answer. Please also show your work if a
large box is provided. For all coding questions, you may use commas and/or one or more
function calls in each blank.
For all Python questions, you may assume Pandas has been imported as pd, NumPy has
been imported as np, and Plotly Express has been imported as px.
You MUST write your Student ID number at the top of each page.
Honor Code [1 Pt]:
As a member of the UC Berkeley community, I act with honesty, integrity, and respect
for others. I am the person whose name is on the exam, and I completed this exam in
accordance with the Honor Code.
Signature:
1
,CS 189/289A Midterm, Page 2 of 23 SID:
This page has been intentionally left blank.
, CS 189/289A Midterm, Page 3 of 23 SID:
1 Matching the Loss Surface
The following plots depict the error surfaces for several models on different datasets. The contour
plots show the contours of the error surface. Use these plots to answer the questions below.
60
35 50
50
30
40 40
25
30
Error
Error
Error
20 30
15 20 20
10 10 10
5
0 0
−6 −4 −2 0 2 4 6 −6 −4 −2 0 2 4 6 −6 −4 −2 0 2 4 6
w w w
(A) (B) (C)
(D) (E) (F)
(a) [1 Pt] Which of the following most accurately describes the loss surface in Figure (A)?
⃝ This is the loss for a least squares regression problem.
⃝ This is the loss of a linearly separable classification problem.
⃝ Significant L2 regularization is needed for this loss surface.
⃝ This is the loss of the classification problem.
(b) [2 Pts] Which of the above loss functions corresponds to the cross entropy loss for a logistic
regression model of the form y(x) = σ (x × w) where x, w ∈ R with the following data:
⃝ (A)
class 1
⃝ (B)
⃝ (C)
⃝ (D)
label
⃝ (E)
⃝ (F)
class 0
−3 −2 −1 0 1 2 3
x