InferenceAI

Enter at least two characters to search.

Start free

Normalize a Vector

easyEmbeddings12 min10 XP

Return the L2-normalized vector rounded element-wise to six decimals. Return a zero vector unchanged.

Examples

EXAMPLE WALKTHROUGHunit vector

A guided view of the published example, not a trace of your code.

INPUT[[3,4]]
TASKnormalize_vector()
EXPECTED OUTPUT[0.6,0.8]

Start with the input values shown in this example.

Example 1 of 2

Input: values = [3,4]

Output: [0.6,0.8]

Explanation: unit vector

Input: values = [0,0]

Output: [0,0]

Explanation: zero

Hint 1

Divide each value by the L2 norm.

Topics

PythonEmbeddings