We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
easy
primitives
Implement Cosine Similarity
Implement cosine similarity between two vectors.
$$\text{cos\_sim}(a, b) = \frac{a \cdot b}{\|a\| \cdot \|b\|}$$
where $\|a\| = \sqrt{\sum_i a_i^2}$ is the L2 norm.
Input: Two 1D tensors a and b of the same shape
Output: A scalar representing the cosine similarity (value between -1 and 1)
Hints
similarity
linear-algebra
basics
Sign in to attempt this problem and view the solution.