Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: L2 Normalization and Norm Comparison | Normalization Techniques
Feature Scaling and Normalization Deep Dive

bookChallenge: L2 Normalization and Norm Comparison

Task

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.

  1. Compute row-wise L2 norms as a column vector row_norms with shape (n_samples, 1) using np.linalg.norm(..., axis=1, keepdims=True).
  2. Create X_l2 by dividing each row of X by its L2 norm via broadcasting.
  3. Compute norms_before and norms_after as 1D arrays (shape (n_samples,)) with np.linalg.norm(..., axis=1).
  4. Assume there are no zero rows in X. Do not modify X in place. Use vectorized NumPy operations.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 4
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

Awesome!

Completion rate improved to 5.26

bookChallenge: L2 Normalization and Norm Comparison

Swipe to show menu

Task

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.

  1. Compute row-wise L2 norms as a column vector row_norms with shape (n_samples, 1) using np.linalg.norm(..., axis=1, keepdims=True).
  2. Create X_l2 by dividing each row of X by its L2 norm via broadcasting.
  3. Compute norms_before and norms_after as 1D arrays (shape (n_samples,)) with np.linalg.norm(..., axis=1).
  4. Assume there are no zero rows in X. Do not modify X in place. Use vectorized NumPy operations.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 4
single

single

some-alt