Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
Clear comment, add sanity check, change algorithmic_reverse_nlplike m…
Browse files Browse the repository at this point in the history
…ax_length and add __pycache__ entry in .gitignore
  • Loading branch information
ReDeiPirati committed Jun 28, 2017
1 parent 759789b commit 31f5dfa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Compiled python modules.
*.pyc
# Byte-compiled
__pycache__/

# Python egg metadata, regenerated from source files by setuptools.
/*.egg-info
Expand Down
16 changes: 8 additions & 8 deletions tensor2tensor/bin/t2t-datagen
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ _SUPPORTED_PROBLEM_GENERATORS = {
lambda: algorithmic.multiplication_generator(10, 40, 100000),
lambda: algorithmic.multiplication_generator(10, 400, 10000)),
"algorithmic_reverse_nlplike_decimal8K": (
lambda: algorithmic.reverse_generator_nlplike(8000, 40, 100000,
10, 1.250),
lambda: algorithmic.reverse_generator_nlplike(8000, 400, 10000,
10, 1.250)),
lambda: algorithmic.reverse_generator_nlplike(8000, 70, 100000,
10, 1.300),
lambda: algorithmic.reverse_generator_nlplike(8000, 700, 10000,
10, 1.300)),
"algorithmic_reverse_nlplike_decimal32K": (
lambda: algorithmic.reverse_generator_nlplike(32000, 40, 100000,
10, 1.005),
lambda: algorithmic.reverse_generator_nlplike(32000, 400, 10000,
10, 1.005)),
lambda: algorithmic.reverse_generator_nlplike(32000, 70, 100000,
10, 1.050),
lambda: algorithmic.reverse_generator_nlplike(32000, 700, 10000,
10, 1.050)),
"algorithmic_algebra_inverse": (
lambda: algorithmic_math.algebra_inverse(26, 0, 2, 100000),
lambda: algorithmic_math.algebra_inverse(26, 3, 3, 10000)),
Expand Down
7 changes: 6 additions & 1 deletion tensor2tensor/data_generators/algorithmic.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ def zipf_random_sample(distr_map, sample_len):
"""
u = np.random.random(sample_len)
return [t+1 for t in np.searchsorted(distr_map, u)] # 0 pad and 1 EOS
# Random produces values in range [0.0,1.0); even if it is almost
# improbable(but possible) that it can generate a clear 0.000..0,
# we have made a sanity check to overcome this issue. On the other hand,
# t+1 is enough from saving us to generate PAD(0) and EOS(1) which are
# reservated symbols.
return [t+1 if t > 0 else t+2 for t in np.searchsorted(distr_map, u)]


def reverse_generator_nlplike(nbr_symbols, max_length, nbr_cases, \
Expand Down

0 comments on commit 31f5dfa

Please sign in to comment.