Code Monkey home page Code Monkey logo

word2vec_assignment's Introduction

word2vec_assignment

A pytorch-based word2vec exploratory assignment, using jupyter notebook and Python 3.

Installation

To get started, download the repository:

git clone https://github.com/theevann/word2vec_assignment

To automatically download the requirements, you must have Conda installed (I highly recommend it for environment management). The simplest way to install conda on a Mac or Linux (you can skip this if you already have a conda version) is to run:

curl https://conda.ml | sh

For those of you on Windows, you can use the GitHub Desktop App, and follow the Conda install guide for Windows.

Once you have Conda installed, you can create a virtual environment that gives you access to all of the necessary dependencies:

cd word2vec_assignment

If you are on Linux or OS X:

conda env create -f requirements.yml

If you are on Windows:

conda env create -f windows_requirements.yml

If you are having trouble installing PyTorch, it might be useful to read the installation documentation. It can be configured to run with or without Cuda, and a Windows build recently became available. For the purpose of this assignment, you do not need Cuda installed.

Download Data

To download and preprocess the data, run the following commands:

cd data
sh fetch_imdb.sh
cd ..

For people using Windows, the wget used in the script might fail. In this case, you can try downloading the dataset manually:

  1. Click on Large Movie Review Dataset v1.0

    download that to:

    YOUR/PATH/TO/word2vec_assignment/data/
    

    YOUR/PATH/TO is the path to the directory you git-cloned.

  2. extract it with the tool of your choice.

  3. delete aclImdb_v1.tar.gz to save space.

  4. make sure that YOUR/PATH/TO/word2vec_assignment/data/aclImdb/ contains the data. You should see:

    README
    imdb.vocab
    imdbEr.txt
    test/
    train/
    

    in that directory

Starting the Jupyter Notebook

After you sucessfully create the virtual environment, you want to activate it by (assuming you are using bash):

source activate pytorch_w2v

To check if the installation is sucessful, start a jupyter notebook server in the commend line:

jupyter notebook

You should see a web page pops up in your web browser. Click on the folder w2v_hw, and open w2v_hw.ipynb.

If you are not familiar with jupyter notebook, here and here are two short tutorials. Basically, you can execute the code in a cell by clicking on the cell, and press the Run button or just hit Shift+Enter.

Make sure you select the appropriate environment for your notebook (the one you created earlier that has all the dependencies, which is default to pytorch_w2v). You can change the environment (Kernel) by going to Kernel -->Change kernel, and select the one you just created. Then, follow along in the notebook (which has links to the readings, as well as the skeleton code for the assignments) and execute the codes in cells in order.

After you finish, you can deavtivate the environment by (again, assuming you are using bash):

source deactivate

word2vec_assignment's People

Contributors

theevann avatar sidenver avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.