Challenge: L2 Normalization and Norm Comparison
Завдання
Swipe to start coding
You are given a NumPy array X of shape (n_samples, n_features).
Your goal is to L2-normalize each row (sample) and compare norms before and after normalization using np.linalg.norm.
- Compute row-wise L2 norms as a column vector
row_normswith shape(n_samples, 1)usingnp.linalg.norm(..., axis=1, keepdims=True). - Create
X_l2by dividing each row ofXby its L2 norm via broadcasting. - Compute
norms_beforeandnorms_afteras 1D arrays (shape(n_samples,)) withnp.linalg.norm(..., axis=1). - Assume there are no zero rows in
X. Do not modifyXin place. Use vectorized NumPy operations.
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 4
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Suggested prompts:
Can you explain this in simpler terms?
What are the next steps I should take?
Can you provide an example?
Awesome!
Completion rate improved to 5.26
Challenge: L2 Normalization and Norm Comparison
Свайпніть щоб показати меню
Завдання
Swipe to start coding
You are given a NumPy array X of shape (n_samples, n_features).
Your goal is to L2-normalize each row (sample) and compare norms before and after normalization using np.linalg.norm.
- Compute row-wise L2 norms as a column vector
row_normswith shape(n_samples, 1)usingnp.linalg.norm(..., axis=1, keepdims=True). - Create
X_l2by dividing each row ofXby its L2 norm via broadcasting. - Compute
norms_beforeandnorms_afteras 1D arrays (shape(n_samples,)) withnp.linalg.norm(..., axis=1). - Assume there are no zero rows in
X. Do not modifyXin place. Use vectorized NumPy operations.
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 4
single