교재: Deisenroth·Faisal·Ong, Mathematics for Machine Learning (mml-book.github.io에 공개된 PDF, 2024-01-15 판). 절과 식 번호는 그 PDF 기준이다. 답과 풀이:다음 편에 있다. 숫자 답은 모두 sympy·numpy로 검산했고, 풀이에 적은 교재 절·식 번호는 PDF 원문과 대조했다. 범위와 시간: 기초수학 = MML Part 1(27장) 60분, 기초 AI = MML Part 2(812장) 60분을 가정했다.
이 범위로 보는 필기시험의 응시 후기를 모아 보면, 1시간에 5~6문제가 나오고 교재의 기본 개념(정사영, 기울기 계산, 최적화 등)을 끝까지 계산할 수 있는지를 묻는 해가 많았다. 그런데 출제자가 해마다 바뀌어 체감 난이도가 크게 오른 해도 있었고, 같은 교재를 범위로 하는 다른 필기에서는 지문이 모두 영어이고 문제 대부분이 증명인 경우도 있었다. 그래서 과목마다 두 세트를 만들었다.
(a) A의 고윳값과 고유벡터를 구하라.
(b) A=PDP−1로 대각화하고 An을 n의 식으로 써라. n=1을 넣어 검산하라.
(c) A의 두 고유벡터는 서로 직교하는가? 스펙트럼 정리와 연결해 설명하라.
(d) C의 촐레스키 분해 C=LL⊤(L은 대각 원소가 양수인 하삼각행렬)를 구하라.
(a) 기울기 ∇f(교재 관례대로 1×2 행벡터)를 구하고 점 (1,0)에서의 값을 구하라.
(b) (1,0)에서의 헤시안을 구하라.
(c) (1,0) 근처의 2차 테일러 다항식을 δ=x−(1,0)⊤로 써라.
(d) g(x)=∥Ax−b∥2, A=101210, b=(1,1,1)⊤일 때 dxdg를 행렬 식으로 쓰고 x0=(1,0)⊤에서의 값을 구하라. g를 최소로 하는 x도 구하라.
(a) 기계 A, B, C가 제품을 각각 50%, 30%, 20% 만들고 불량률은 1%, 2%, 5%다. 무작위로 고른 제품이 불량일 확률과, 불량품이 C에서 나왔을 확률을 구하라.
(b) 분산의 정의 V[x]=E[(x−E[x])2]에서 출발해 V[x]=E[x2]−(E[x])2를 유도하라.
(c) x=(x1,x2)⊤∼N(μ,Σ), μ=(1,2)⊤, Σ=[2112]일 때 다음을 구하라.
(i) 주변분포 p(x1) (ii) 조건부분포 p(x1∣x2=4) (iii) y=x1−x2의 분포 (iv) E[x1x2]
(a) f(x)=21x⊤Qx−b⊤x, Q=diag(1,4), b=(1,2)⊤.
(i) 최솟점 x∗를 구하라.
(ii) x0=0, 학습률 γ=0.2로 경사하강법을 두 번 진행해 x1,x2를 구하라.
(iii) 오차 ek=xk−x∗가 ek+1=(I−γQ)ek를 따름을 보이고, 수렴하는 γ의 범위와 가장 빨리 수렴하는 γ를 구하라.
(b) minx12+x22 subject to x1+x2≥2.
(i) 제약을 g(x)≤0 꼴로 바꾸고 라그랑지안을 써라.
(ii) 쌍대 함수 D(λ)=minxL(x,λ)를 구하라.
(iii) 쌍대 문제를 풀고, 원 문제의 최적값과 같음을 확인하라.
(a) σ2=4를 알 때 음의 로그 가능도 L(μ)를 쓰고 μML을 구하라.
(b) μ와 σ2를 모두 모를 때 σML2을 구하라.
(c) σ2=4를 알고 사전분포가 μ∼N(0,1)일 때 사후분포 p(μ∣X)와 μMAP을 구하라.
(d) 데이터가 아주 많아지면 μMAP과 μML은 어떻게 되는가? 사후분포의 정밀도(분산의 역수)로 설명하라.
(a) 방향 그래프 a→c←b, c→d. 결합분포를 인수분해하고 다음이 성립하는지 판정하라.
(i) a⊥⊥b (ii) a⊥⊥b∣d (iii) a⊥⊥d∣c
(b) 경험적 위험(empirical risk)을 식으로 정의하라. 경험적 위험을 최소화한 예측기가 과적합될 수 있는 이유를 쓰고, 정규화는 목적함수에 무엇을 더하는지 쓰라.
(c) 데이터 N=50개에 두 모델을 맞췄다. 모델 1은 매개변수 M=3개, 최대 로그 가능도 −80. 모델 2는 M=6개, −75. 교재 (8.48)의 AIC logp(x∣θ)−M과 (8.49)의 BIC logp(x∣θ)−21MlogN으로 각각 어느 모델을 고르는가? (ln50≈3.912)
1차원 데이터 0,2,4, K=2. 초기값 π=(0.5,0.5), μ=(0,4), σ12=σ22=1. (e−8≈3.4×10−4이므로 0으로 근사해도 된다.)
(a) E 단계: 세 점의 책임도 rn1,rn2를 구하라.
(b) M 단계: Nk, μk, σk2, πk를 구하라.
(c) GMM 로그 가능도를 미분해 0으로 놓아도 닫힌 해가 바로 나오지 않는 이유를 쓰라. EM이 반복마다 보장하는 것은 무엇인가?
(d) 책임도를 0 또는 1로만 정하고 공분산을 무시(단위행렬로 고정)하면 어떤 알고리즘과 같아지는가?
(a) 초평면 w=(1,1)⊤, b=−1이 모든 점에서 yn(w⊤xn+b)≥1을 만족함을 확인하고, 마진(초평면에서 가장 가까운 점까지의 거리)을 구하라.
(b) 서포트 벡터는 어느 점인가? w=∑nαnynxn과 ∑nαnyn=0을 이용해 쌍대 변수 αn을 구하고, 쌍대 목적값이 원 목적값 21∥w∥2과 같음을 확인하라.
(c) 같은 (w,b)에서 음성 점 (1,0.5)와 (0.5,0.25)의 힌지 손실 max{0,1−yf(x)}을 구하라. 각 점은 마진 밖, 마진 안, 오분류 중 어디인가?
(d) 커널 k(x,z)=(x⊤z)2에 해당하는 특징 맵 ϕ:R2→R3을 쓰고, x=(1,2), z=(3,1)에서 k(x,z)=ϕ(x)⊤ϕ(z)를 확인하라.
Part 1 B형: Basic Mathematics (60 min, 6 problems, English)#
난이도가 오른 경우를 가정한 세트다. 영어 지문으로 출제되는 경우에 대비해 지문을 영어로 쓰고, 문제마다 아래에 우리말 요지를 붙였다.
1-B1. Vector spaces and linear maps (15 pts) [Ch. 2]#
(a) Show that U={x∈R3:x1+2x2−x3=0} is a subspace of R3. Find a basis of U and dimU.
(b) Let Φ:R3→R2, Φ(x)=(x1+x2,x2−x3)⊤. Find kerΦ, rkΦ and ImΦ. Then find the transformation matrix A~Φ of Φ with respect to the ordered bases B~=((1,1,0)⊤,(0,1,1)⊤,(1,0,1)⊤) of R3 and C~=((1,1)⊤,(1,−1)⊤) of R2.
(c) Prove that rk(A⊤A)=rk(A) for every A∈Rm×n.
1-B2. Inner products, angles and rotations (15 pts) [Ch. 3]#
Let ⟨x,y⟩A:=x⊤Ay with A=[2−1−11].
(a) Show that ⟨⋅,⋅⟩A is an inner product on R2.
(b) Compute the angle between e1=(1,0)⊤ and e2=(0,1)⊤ with respect to ⟨⋅,⋅⟩A.
(c) Compute the orthogonal projection of x=(1,1)⊤ onto span{e1} with respect to ⟨⋅,⋅⟩A, and find the orthogonal complement of span{e1} under this inner product.
(d) Let R(θ)=[cosθsinθ−sinθcosθ]. Show that R(θ) is orthogonal, detR(θ)=1, and R(θ) preserves the standard inner product (hence lengths and angles). Show R(α)R(β)=R(α+β).
요지: 내적 판정, 그 내적에서의 각도·사영·직교여공간, 회전행렬 성질 증명
1-B3. Singular value decomposition (20 pts) [Ch. 4]#
A=[32232−2].
(a) Compute an SVD A=UΣV⊤: all singular values, U, and V (including a unit vector spanning kerA).
(b) Find the best rank-1 approximation A^(1) and compute ∥A−A^(1)∥2 and ∥A−A^(1)∥F.
(c) Show that the nonzero eigenvalues of A⊤A are the squared singular values of A, and that ∥A∥F2=∑iσi2.
1-B4. Matrix calculus and backpropagation (15 pts) [Ch. 5]#
(a) For f(x)=x⊤Ax with A∈Rn×n (not necessarily symmetric), show from the definition of partial derivatives that dxdf=x⊤(A+A⊤).
(b) Let L(W)=∥y−Wx∥2 with W∈R2×3. Show that dWdL=−2(y−Wx)x⊤ and evaluate it for W=[101110], x=(1,0,2)⊤, y=(1,2)⊤.
(c) Consider z=W1x, h=ReLU(z) (elementwise), y^=w2⊤h, L=21(y^−y)2 with x=(1,2)⊤, W1=[10−11], w2=(3,1)⊤, y=1.
(i) Compute the forward pass z,h,y^,L.
(ii) Compute ∂L/∂w2, ∂L/∂z, ∂L/∂W1, ∂L/∂x.
(iii) Take one gradient step on W1 only with step size γ=0.1 and compute the new loss.
요지: 이차형식 미분 증명, 행렬에 대한 미분, 작은 신경망 역전파 손계산
1-B5. Probability and distributions (15 pts) [Ch. 6]#
(a) Let X∼Bin(N,μ). Writing X as a sum of N independent Bernoulli variables, prove E[X]=Nμ and V[X]=Nμ(1−μ).
(b) A coin has unknown bias μ with prior Beta(1,3). You observe 7 heads in 10 tosses. Find the posterior, its mean, its mode (μMAP), and compare them with μML.
(c) x∼N(1,4) and y∣x∼N(2x−1,1). Find p(y), Cov[x,y] and p(x∣y=5).
(d) X∼U(0,1) and Y=−lnX. Find the pdf of Y using the change-of-variables technique.
요지: 이항분포 평균·분산 증명, 베타-이항 켤레, 가우시안 선형 모델의 주변·조건부, 변수 변환
1-B6. Optimization and convexity (20 pts) [Ch. 5, 7]#
(a) f(x,y)=x4+y2−2xy. Find all stationary points and classify each using the Hessian. Is f convex? What is the global minimum value?
(b) Solve min(x1−2)2+(x2−1)2 subject to x1+x2≤2. Verify the KKT conditions, then derive the Lagrangian dual function D(λ) and show that strong duality holds.
(c) Show that φ(t)=−logt is convex on t>0. Using Jensen’s inequality, prove E[logX]≤logE[X] for a positive random variable X, and check it for X uniform on {1,4}.
요지: 정류점 분류, KKT와 쌍대, 볼록성과 젠센 부등식(볼록·오목 성질로 푸는 확률 문제)
Part 2 B형: Basic AI (60 min, 6 problems, English)#
2-B1. Parameter estimation and regularization (15 pts) [Ch. 8, 9]#
(a) Let x1,…,xN be i.i.d. from p(x∣λ)=λe−λx (x≥0). Derive λML and verify that it is a maximum. Compute it for the data {1,2,3,2}.
(b) Linear regression yn=ϕ(xn)⊤θ+ϵ, ϵ∼N(0,σ2), prior θ∼N(0,b2I). Show that MAP estimation is equivalent to minimizing ∥y−Φθ∥2+λ∥θ∥22 and identify λ.
(c) Which prior on θ makes MAP estimation equivalent to L1-regularized regression (LASSO)? Write the negative log-posterior.
2-B2. Bayesian linear regression (20 pts) [Ch. 9]#
y=θ0+θ1x+ϵ, ϵ∼N(0,1), prior θ∼N(0,I). Data (x,y): (0,1),(1,2),(2,4).
(a) By completing the square in logp(θ∣X,Y), derive SN=(S0−1+σ−2Φ⊤Φ)−1 and mN=SN(S0−1m0+σ−2Φ⊤y).
(b) Compute SN and mN, and compare mN with θML.
(c) Compute the posterior predictive distribution p(y∗∣X,Y,x∗=3). Which part of its variance comes from parameter uncertainty?
(d) Write the marginal likelihood p(Y∣X) as a Gaussian and give its covariance matrix numerically. What is it used for?
요지: 베이즈 선형회귀 사후분포 유도·계산, 예측분포, 주변 가능도
2-B3. PCA: projection view and computation (15 pts) [Ch. 10]#
(a) For centered data with covariance S, let b1,…,bD be an orthonormal basis and project onto span{b1,…,bM}. Show that the average squared reconstruction error is JM=∑j=M+1Dbj⊤Sbj, and conclude that its minimum is ∑j=M+1Dλj.
(b) D=3, N=2, centered data matrix X=122−1−2−2 (columns are data points). Use the N<D trick: find the top eigenvector of N1X⊤X and recover the principal direction u1 of S=N1XX⊤ and λ1.
(c) Relate λ1 to the largest singular value of X.
(d) In probabilistic PCA, p(x)=N(x∣μ,BB⊤+σ2I). For B=(1,2,2)⊤ and σ2=0.5, find the eigenvalues and the top eigenvector of the covariance, and relate them to (b).
2-B4. EM for Gaussian mixtures: derivations (15 pts) [Ch. 11]#
(a) For L=∑nlog∑kπkN(xn∣μk,Σk), show that ∂L/∂μk=0 gives μk=Nk1∑nrnkxn, where rnk is the responsibility and Nk=∑nrnk.
(b) Derive πk=Nk/N using a Lagrange multiplier for ∑kπk=1.
(c) 1D, K=2, π=(0.4,0.6), μ=(0,3), σ2=(1,4). Given N(1∣0,1)≈0.2420 and N(1∣3,4)≈0.1210, compute the responsibilities of x=1.
(d) Explain why maximum likelihood for a GMM can degenerate (likelihood →∞).
(a) Starting from the soft-margin primal (12.26a) minw,b,ξ21∥w∥2+C∑nξn s.t. yn(w⊤xn+b)≥1−ξn, ξn≥0, derive the dual problem and show the box constraint 0≤αn≤C.
(b) Show that the primal is equivalent to minw,b21∥w∥2+C∑nmax{0,1−yn(w⊤xn+b)}.
(c) Using complementary slackness, describe where a point lies when αn=0, 0<αn<C, and αn=C.
(d) Let w=(1,−1)⊤, b=0, C=1 and the data (2,0)(+1), (0.5,0)(+1), (0,1)(−1), (1,0)(−1). Compute ynf(xn), the hinge losses, and the objective. If this (w,b) were optimal, what values could each αn take? Use w=∑nαnynxn and ∑nαnyn=0 to decide whether it is actually optimal.
요지: 소프트 마진 쌍대 유도, 힌지 손실과의 동치, 상보 여유성, 숫자로 최적성 판정
2-B6. Short essays (15 pts, answer 3 of 5) [Ch. 8–12]#
(1) Explain why the maximum-likelihood prediction ΦθML in linear regression is the orthogonal projection of y onto the column space of Φ.
(2) Explain the relation among PCA, the SVD of the data matrix, and the Eckart–Young theorem.
(3) Compare a GMM fitted by EM with K-means.
(4) Why is the SVM dual useful? What must a valid kernel satisfy? Check that the Gram matrix of k(x,z)=(x⊤z)2 on x1=(1,0), x2=(0,1), x3=(1,1) is positive semidefinite.
(5) Explain nested cross-validation and why the cross-validation score of the selected model is optimistic.
요지: 서술형 5개 중 3개. 사영과 회귀, PCA·SVD·Eckart–Young, GMM과 K-평균, 쌍대와 커널, 중첩 교차검증