Skip to content

Commit

Permalink
some corr
Browse files Browse the repository at this point in the history
  • Loading branch information
siddsax committed Nov 16, 2018
1 parent b255786 commit fc4ce47
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ datasets
*.npy
*.npz
*.pyc
embedding_weights/*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Pytorch implementation of the paper http://nyc.lti.cs.cmu.edu/yiming/Publication
## Dependencies

* NLTK (stopwords)
* Pytorch
* Pytorch >= 0.3.1
* Gensim
* Matplotlib

Expand Down
4 changes: 2 additions & 2 deletions code/cnn_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_class(x_te, y_te, params, model=None, x_tr=None, y_tr=None, embedding_w
prec = precision_k(y_tr, Y, 5)
print('Test Loss; Precision Scores [1->5] {} Cross Entropy {};'.format(prec, loss))

y_te = y_te[:,:-1]
#y_te = y_te[:,:-1]
x_te, _ = load_batch_cnn(x_te, y_te, params, batch=False)
Y2 = np.zeros(y_te.shape)
rem = x_te.shape[0]%params.mb_size
Expand All @@ -67,4 +67,4 @@ def test_class(x_te, y_te, params, model=None, x_tr=None, y_tr=None, embedding_w
Y_probabs2 = sparse.csr_matrix(Y2)
sio.savemat('score_matrix.mat' , {'score_matrix': Y_probabs2})

return prec[0], loss
return prec[0], loss
4 changes: 2 additions & 2 deletions code/cnn_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def train(x_tr, y_tr, x_te, y_te, embedding_weights, params):
win = viz.line(X=np.arange(iteration, iteration + .1), Y=np.arange(0, .1))
iteration +=1

if(epoch==0):
break
#if(epoch==0):
# break

if(totalLoss<bestTotalLoss):

Expand Down
7 changes: 4 additions & 3 deletions utils/w2v.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def train_word2vec(sentence_matrix, vocabulary_inv,
min_word_count # Minimum word count
context # Context window size
"""
model_dir = 'word2vec_models'
model_dir = '../embedding_weights'
model_name = "{:d}features_{:d}minwords_{:d}context".format(num_features, min_word_count, context)
model_name = join(model_dir, model_name)
if exists(model_name):
Expand Down Expand Up @@ -62,7 +62,7 @@ def load_word2vec(params):
num_features # Word vector dimensionality
"""

model_dir = 'word2vec_models'
model_dir = '../embedding_weights'

if params.model_type == 'GoogleNews':
model_name = join(model_dir, 'GoogleNews-vectors-negative300.bin.gz')
Expand All @@ -73,7 +73,8 @@ def load_word2vec(params):

elif params.model_type == 'glove':
model_name = join(model_dir, 'glove.6B.%dd.txt' % (params.num_features))
assert(exists(model_name))
print(model_name)
assert(exists(model_name))
print('Loading existing Word2Vec model (Glove.6B.%dd)' % (params.num_features))

# dictionary, where key is word, value is word vectors
Expand Down

0 comments on commit fc4ce47

Please sign in to comment.