Word embeddings

We will now train a neural network for word to vector representation. Given a particular word in the center of a sentence, which is the input word, we look at the words nearby. The network is going to tell us the probability for every word in our vocabulary of being the nearby word that we choose.

import timeimport tensorflow as tfimport numpy as npimport utilityfrom tqdm import tqdmfrom urllib.request import urlretrievefrom os.path import isfile, isdirimport zipfilefrom collections import Counterimport randomdataDir = 'data'dataFile = 'text8.zip'datasetName = 'text 8 data set''''track progress of file download'''class DownloadProgress(tqdm): ...

Get Neural Network Programming with TensorFlow now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.