keras.preprocessing.sequences: Re-add seed parameter to skipgrams.
Fixes
@@ -114,7 +114,7 @@ def make_sampling_table(size, sampling_factor=1e-5):
def skipgrams(sequence, vocabulary_size,
window_size=4, negative_samples=1., shuffle=True,
- categorical=False, sampling_table=None):
+ categorical=False, sampling_table=None, seed=None):
"""Generates skipgram word pairs.
Takes a sequence (list of indexes of words),
@@ -140,6 +140,7 @@ def skipgrams(sequence, vocabulary_size,
if True labels will be categorical eg. [[1,0],[0,1],[0,1] .. ]
sampling_table: 1D array of size `vocabulary_size` where the entry i
encodes the probabibily to sample a word of rank i.
+ seed: random seed.
# Returns
couples, labels: where `couples` are int pairs and
@@ -184,6 +185,7 @@ def skipgrams(sequence, vocabulary_size,
labels += [0] * num_negative_samples
if shuffle:
+ if seed is None:
seed = random.randint(0, 10e6)
random.seed(seed)
random.shuffle(couples)
