O'Reilly logo

Deep Learning By Example by Ahmed Menshawy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Data analysis and pre-processing

In this section, we are going to define some helper functions that will enable us to build a good Word2Vec model. For this implementation, we are going to use a cleaned version of Wikipedia (http://mattmahoney.net/dc/textdata.html).

So, let's start off by importing the required packages for this implementation:

#importing the required packages for this implementationimport numpy as npimport tensorflow as tf#Packages for downloading the datasetfrom urllib.request import urlretrievefrom os.path import isfile, isdirfrom tqdm import tqdmimport zipfile#packages for data preprocessingimport refrom collections import Counterimport random

Next up, we are going to define a class that will be used to download the dataset ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required