🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Regularisation (Ridge and Lasso): all 10 questions

Quiz: Regularisation (Ridge and Lasso) · Question 5 of 10

What does this print? (code)

What does this print?

import numpy as np
w = np.array([3.0, -4.0])
print(np.sum(w ** 2), np.sum(np.abs(w)))
  1. A.7.0 7.0
  2. B.25.0 7.0
  3. C.25.0 -1.0
  4. D.5.0 7.0
Answer & explanation

Correct answer: 25.0 7.0

The L2 penalty sums squares (9 + 16); the L1 penalty sums absolute values (3 + 4).

Can you get the rest right without peeking?

Take the timed Quiz: Regularisation (Ridge and Lasso) quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →