← 返回 openai 的题目列表Reproduce Double Descent in Linear Regression
类型:online_judge
Problem: Reproduce Double Descent in Linear Regression
You need to reproduce the double descent phenomenon in the simplest linear regression setting using Python/PyTorch, and explain the observed behavior.
Background
Consider synthetic data:
[ y = X w^* + \epsilon ]
where:
(X) is a Gaussian feature matrix;
(w^*) is the ground-truth linear weight vector;
(\epsilon) is Gaussian noise;
the number of training samples is (n), and the number of test samples is (m);
the model uses the first (p) features for linear regression;
(p) is varied from below (n) to above (n).
You should observe whether the test error spikes when the number of parameters (p) approaches the number of training samples (n), and whether it decreases again in the over-parameterized regime (p > n).
Requirements
Complete the following tasks:
Generate synthetic linear regression data using Python/PyTorch.
Train a linear regression model for different feature dimensions / parameter counts (p).
For each (p), record:
training MSE;
test MSE.
Plot training MSE and test MSE as functions of (p).
Try to reproduce double descent across:
the under-parameterized regime: (p < n);
the interpolation threshold: (p \approx n);
the over-parameterized regime: (p > n).
Explain why double descent happens.
Propose ways to mitigate the test error spike and discuss the trade-offs.
Suggested Experimental Parameters
You may use the following default parameters or tune them yourself:
n_train = 80
n_test = 2000
d_max = 200
noise_std = 0.5
p_values = 1, 2, ..., 200
Input / Output Format
If implemented as a script, read from stdin:
n_train n_test d_max noise_std seed k
p1 p2 ... pk
Print the training MSE and test MSE for each p:
p train_mse test_mse
In the actual interview, the notebook, plots, explanation, and discussion are usually more important than fixed stdout.
Example
Input
80 2000 200 0.5 0 5
20 60 80 100 160
Output
Print 5 lines in the format: p train_mse test_mse. The test MSE should typically be largest near p = 80.