Skip to content
Open
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
9 changes: 7 additions & 2 deletions glove/glove.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import numpy as np
import scipy.sparse as sp
import numbers
import sys

from .glove_cython import fit_vectors, transform_paragraph

Expand Down Expand Up @@ -163,8 +164,12 @@ def transform_paragraph(self, paragraph, epochs=50, ignore_missing=False):

random_state = check_random_state(self.random_state)

word_ids = np.array(cooccurrence.keys(), dtype=np.int32)
values = np.array(cooccurrence.values(), dtype=np.float64)
if (sys.version_info.major < 3):
word_ids = np.array(cooccurrence.keys(), dtype=np.int32)
values = np.array(cooccurrence.values(), dtype=np.float64)
else:
word_ids = np.array(list(cooccurrence.keys()), dtype=np.int32)
values = np.array(list(cooccurrence.values()), dtype=np.float64)
shuffle_indices = np.arange(len(word_ids), dtype=np.int32)

# Initialize the vector to mean of constituent word vectors
Expand Down