Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed major errors #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To get started, cd into the directory examples/ and run demo.sh. It downloads th
* sim_sif.py and sim_tfidf.py are for the textual similarity tasks in the paper,
* supervised_sif_proj.sh is for the supervised tasks in the paper.

Check these files to see the options.
Check these files to see the options. Make sure you create "log" folder in "example" directory before running above code.

## Source code
The code is separated into the following parts:
Expand Down
2 changes: 1 addition & 1 deletion examples/sif_embedding.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
word2weight = data_io.getWordWeight(weightfile, weightpara) # word2weight['str'] is the weight for the word 'str'
weight4ind = data_io.getWeight(words, word2weight) # weight4ind[i] is the weight for the i-th word
# load sentences
x, m, _ = data_io.sentences2idx(sentences, words) # x is the array of word indices, m is the binary mask indicating whether there is a word in that location
x, m = data_io.sentences2idx(sentences, words) # x is the array of word indices, m is the binary mask indicating whether there is a word in that location
w = data_io.seq2weight(x, m, weight4ind) # get word weights

# set parameters
Expand Down
2 changes: 1 addition & 1 deletion examples/train.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cd ../src
THEANO_FLAGS=mode=FAST_RUN,device=cpu,floatX=float32 python train.py $@
THEANO_FLAGS=mode=FAST_RUN,device=cpu,floatX=float32 python2.7 train.py $@
1 change: 1 addition & 0 deletions src/data_io.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def sentences2idx(sentences, words):
:param words: a dictionary, words['str'] is the indices of the word 'str'
:return: x1, m1. x1[i, :] is the word indices in sentence i, m1[i,:] is the mask for sentence i (0 means no word at the location)
"""
seq1 = []
for i in sentences:
seq1.append(getSeq(i,words))
x1,m1 = prepare_data(seq1)
Expand Down