2573c649518391ada6214cfc72d20421dfac4072,src/preprocess.py,,get_embeddings,#Any#Any#Any#,194
Before Change
embeddings = np.zeros((word_v_size, d_word))
for idx in range(word_v_size): // kind of hacky
word = vocab.get_token_from_index(idx)
if word == "@@PADDING@@" or word == "@@UNKNOWN@@":
continue
try:
assert word in word2vec
except AssertionError as error:
log.debug(error)
pdb.set_trace()
embeddings[idx] = word2vec[word]
embeddings[vocab.get_token_index("@@PADDING@@")] = 0.
embeddings = torch.FloatTensor(embeddings)
After Change
"""Get embeddings for the words in vocab"""
word_v_size, unk_idx = vocab.get_vocab_size("tokens"), vocab.get_token_index(vocab._oov_token)
embeddings = np.random.randn(word_v_size, d_word) //np.zeros((word_v_size, d_word))
with open(vec_file) as vec_fh:
for line in vec_fh:
word, vec = line.split(" ", 1)
idx = vocab.get_token_index(word)
if idx != unk_idx:
idx = vocab.get_token_index(word)
embeddings[idx] = np.array(list(map(float, vec.split())))
embeddings[vocab.get_token_index("@@PADDING@@")] = 0.
embeddings = torch.FloatTensor(embeddings)
log.info("\tFinished loading embeddings")
return embeddings
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
Instances Project Name: jsalt18-sentence-repl/jiant
Commit Name: 2573c649518391ada6214cfc72d20421dfac4072
Time: 2018-03-16
Author: wang.alex.c@gmail.com
File Name: src/preprocess.py
Class Name:
Method Name: get_embeddings
Project Name: jsalt18-sentence-repl/jiant
Commit Name: 2573c649518391ada6214cfc72d20421dfac4072
Time: 2018-03-16
Author: wang.alex.c@gmail.com
File Name: src/preprocess.py
Class Name:
Method Name: get_embeddings
Project Name: automl/auto-sklearn
Commit Name: 2bffb578491e086ffb39d2740df3c28552ff38d7
Time: 2016-05-10
Author: feurerm@informatik.uni-freiburg.de
File Name: autosklearn/evaluation/abstract_evaluator.py
Class Name: AbstractEvaluator
Method Name: _fit_and_suppress_warnings
Project Name: pantsbuild/pants
Commit Name: 35ba6bfdb63cfedbedfd28c1705996e582178064
Time: 2015-09-23
Author: kwilson@twopensource.com
File Name: src/python/pants/java/nailgun_executor.py
Class Name: NailgunExecutor
Method Name: ensure_connectable