L2 Normalisation Layer and Its Gradient

medium
Unit 11 · Embeddings0/1 to milestone

Embedding models normalise vectors to unit length before computing cosine similarity: y=x∥x∥y = \frac{x}{\|x\|} (with ∥x∥\|x\| clamped below by eps).

Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
L2 Normalisation Layer and Its Gradient · TechGradify