Learn practical skills, build real-world projects, and advance your career

Operations on word vectors

Welcome to your first assignment of this week!

Because word embeddings are very computationally expensive to train, most ML practitioners will load a pre-trained set of embeddings.

After this assignment you will be able to:

  • Load pre-trained word vectors, and measure similarity using cosine similarity
  • Use word embeddings to solve word analogy problems such as Man is to Woman as King is to ______.
  • Modify word embeddings to reduce their gender bias

Updates

If you were working on the notebook before this update...
  • The current notebook is version "2a".
  • You can find your original work saved in the notebook with the previous version name ("v2")
  • To view the file directory, go to the menu "File->Open", and this will open a new tab that shows the file directory.
List of updates
  • cosine_similarity
    • Additional hints.
  • complete_analogy
    • Replaces the list of input words with a set, and sets it outside the for loop (to follow best practices in coding).
  • Spelling, grammar and wording corrections.

Let's get started! Run the following cell to load the packages you will need.

import numpy as np
from w2v_utils import *
Using TensorFlow backend.
Load the word vectors
  • For this assignment, we will use 50-dimensional GloVe vectors to represent words.
  • Run the following cell to load the word_to_vec_map.