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

bookChallenge: L2 Normalization and Norm Comparison

Tâche

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

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 4
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

Suggested prompts:

Can you explain this in simpler terms?

What are the next steps I should take?

Can you provide an example?

close

Awesome!

Completion rate improved to 5.26

bookChallenge: L2 Normalization and Norm Comparison

Glissez pour afficher le menu

Tâche

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 desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 4
single

single

some-alt