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

bookChallenge: L2 Normalization and Norm Comparison

Opgave

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.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 4
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

close

Awesome!

Completion rate improved to 5.26

bookChallenge: L2 Normalization and Norm Comparison

Stryg for at vise menuen

Opgave

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.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 4
single

single

some-alt