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

Commit d2af7cf

Browse files
Added readline import in trainer_utils.py
1 parent c128845 commit d2af7cf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tensor2tensor/utils/trainer_utils.py

100644100755
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,14 +841,19 @@ def _interactive_input_fn(hparams):
841841
vocabulary = p_hparams.vocabulary["inputs" if has_input else "targets"]
842842
# This should be longer than the longest input.
843843
const_array_size = 10000
844+
# For ease of input, activate the readline module if available.
845+
try:
846+
import readline
847+
except ImportError:
848+
pass
844849
while True:
845850
prompt = ("INTERACTIVE MODE num_samples=%d decode_length=%d \n"
846851
" it=<input_type> ('text' or 'image')\n"
847852
" pr=<problem_num> (set the problem number)\n"
848853
" in=<input_problem> (set the input problem number)\n"
849854
" ou=<output_problem> (set the output problem number)\n"
850855
" ns=<num_samples> (changes number of samples)\n"
851-
" dl=<decode_length> (changes decode legnth)\n"
856+
" dl=<decode_length> (changes decode length)\n"
852857
" <%s> (decode)\n"
853858
" q (quit)\n"
854859
">" % (num_samples, decode_length, "source_string"

0 commit comments

Comments
 (0)