All lecture notes, slides and assignments for CS224n: Natural Language Processing with Deep Learning class by Stanford
The videos of all lectures are available on YouTube
This repository includes all my solutions to assignments and also fix for python 3.6.
I made some changes to Python codes because original codes are based on Python 2.
- Put parenthesis to
print()
function. - Changed
xrange()
torange()
- Changed
import cPickle as pickle
toimport pickle
-
URL in get_datasets.sh is not working since link to
glove.6B.50d.txt
is dead. So i changed download link to this github repository and it's working well! Ifget_dataset.sh
does not work, Please let me know.Also, you can use below link to download glove data.
-
In Python 3, You don't have to take care of peculiar encodings in
treebank.py
line 68I changed from
sentences += [[w.lower().decode('utf-8').encode('latin-1') for w in splitted]]
to
sentences += [[w.lower() for w in splitted]]
-
If you run
$ python q3_run.py
, you will see an error below.TypeError: write() argument must be str, not bytes
-
This error is raised since
pickle.dump()
andpickle.load()
do not accept string as input(docs). So, file should be opened in binary mode.# Error! with open("saved_params_%d.npy" % iter, "w") as f: pickle.dump(params, f) # Good! with open("saved_params_$d.npy" % iter, "wb") as f: pickle.dump(params, f)
-
In Question 4,
print >> "~~"
is used to write string to file. But this statement is not supported in Python 3, So i changed those lines toprint("~~", file=f)
-
In
/utils/parser_utils.py
, you should changefrom general_utils
tofrom .general_utils
. I'm not sure why Python cannot find this module, but maybe this error is related to issue withrelative import
orabsolute import
. If you know well about this issue, please let me know.# Not working! from general_utils import logged_loop, get_minibatches # Working! from .general_utils import logged_loop, get_minibatches