+parser = argparse.ArgumentParser(description='Example of double descent with polynomial regression.')
+
+parser.add_argument('--D-max',
+ type = int, default = 16)
+
+parser.add_argument('--nb-runs',
+ type = int, default = 250)
+
+parser.add_argument('--nb-train-samples',
+ type = int, default = 8)
+
+parser.add_argument('--train-noise-std',
+ type = float, default = 0.)
+
+parser.add_argument('--seed',
+ type = int, default = 0,
+ help = 'Random seed (default 0, < 0 is no seeding)')
+
+args = parser.parse_args()
+
+if args.seed >= 0:
+ torch.manual_seed(args.seed)
+
+######################################################################
+
+def pol_value(alpha, x):
+ x_pow = x.view(-1, 1) ** torch.arange(alpha.size(0)).view(1, -1)
+ return x_pow @ alpha
+
+def fit_alpha(x, y, D, a = 0, b = 1, rho = 1e-12):