Solutions for CS224n course from Stanford University: Natural Language Processing with Deep Learning
These past weeks I've spent several weeks on the CS224n course from Stanford University. Here are my solutions to the assignments. These solutions are for the 2017 version of the course.
$ cd \path\to\assignment1
$ conda env -n cs224n python=2.7 anaconda
$ activate cs231n
$ pip install -r requirements.txt
$ deactivate cs224n
If you're working on windows you won't be able to do assignment 2 because the code is for Python 2.7 and TensorFlow is only available with Python 3.5 on windows (at the time I'm writting these lines). So you will need to create another environment for TensorFlow using:
$ conda env -n tensorflow python=3.5 anaconda
$ activate tensorflow
$ pip install -r requirements.txt
$ pip install tensorflow
then you need to convert all the python files from Python 2 to Python 3. To do so you can simply use 2to3
which is a script included in anaconda to convert Python file from version 2 to version 3 automatically. Simply do:
If you're using my files you will need to use Python 3 (on Windows TensorFlow is not compatible with Python 2). Yet, if you want to convert the files from assignment 3 to Python 3, beside using 2to3
, you will need to:
replace line 105 from data_util.py
to:
with open(os.path.join(path, "features.pkl"), "wb") as f:
(Just add a b
to avoid) "write() argument must be str not bytes" error
Also replace line 113 by:
with open(os.path.join(path, "features.pkl"), "rb") as f:
You will also need to replace:
tf.nn.rnn_cell.RNNCell
to
tf.contrib.rnn.core_rnn_cell.RNNCell
in files q2_gru_cell.py
and q2_rnn_cell.py
.
$ 2to3 --output-dir=python3-version/assignment2 -W -n assignment2
Note: If you cloned my repository you won't need to transform the code from Python 2.7 to Python 3.5 as I've already did it
I wrote several blog posts accessible from my website if you want to understand in detail how the code works.