I'm trying to play with tensor2tensor. I follow the document, but it raises an error when I run,
t2t-datagen
--data_dir=$DATA_DIR
--tmp_dir=$TMP_DIR
--num_shards=100
--problem=$PROBLEM
The error is,
This sentence was encoded by the SubwordTextEncoder.
INFO:tensorflow:Trying min_count 4
INFO:tensorflow:Iteration 0
INFO:tensorflow:vocab_size = 99849
INFO:tensorflow:Iteration 1
INFO:tensorflow:vocab_size = 34223
INFO:tensorflow:Iteration 2
INFO:tensorflow:vocab_size = 34955
INFO:tensorflow:Iteration 3
INFO:tensorflow:vocab_size = 34813
[109, 17123, 62, 29963, 22, 41, 4, 19147, 12493, 10749, 34621, 24836, 20, 3]
[u'This_', u'sentence_', u'was_', u'encode', u'd_', u'by_', u'the_', u'Sub', u'word', u'Tex', u't', u'Enco', u'der_', u'._']
This sentence was encoded by the SubwordTextEncoder.
Traceback (most recent call last):
File "/home/feigao/tensorflow/bin/t2t-datagen", line 378, in
tf.app.run()
File "/home/feigao/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 44, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "/home/feigao/tensorflow/bin/t2t-datagen", line 361, in main
training_gen(), FLAGS.problem + UNSHUFFLED_SUFFIX + "-train",
File "/home/feigao/tensorflow/bin/t2t-datagen", line 151, in
lambda: wmt.ende_wordpiece_token_generator(FLAGS.tmp_dir, True, 2**15),
File "/home/feigao/tensorflow/local/lib/python2.7/site-packages/tensor2tensor/data_generators/wmt.py", line 230, in ende_wordpiece_token_generator
tmp_dir, "tokens.vocab.%d" % vocab_size, vocab_size)
File "/home/feigao/tensorflow/local/lib/python2.7/site-packages/tensor2tensor/data_generators/generator_utils.py", line 265, in get_or_generate_vocab
vocab_size, tokenizer.token_counts, 1, 1e3)
File "/home/feigao/tensorflow/local/lib/python2.7/site-packages/tensor2tensor/data_generators/text_encoder.py", line 329, in build_to_target_size
return bisect(min_val, max_val)
File "/home/feigao/tensorflow/local/lib/python2.7/site-packages/tensor2tensor/data_generators/text_encoder.py", line 323, in bisect
other_subtokenizer = bisect(min_val, present_count - 1)
File "/home/feigao/tensorflow/local/lib/python2.7/site-packages/tensor2tensor/data_generators/text_encoder.py", line 323, in bisect
other_subtokenizer = bisect(min_val, present_count - 1)
File "/home/feigao/tensorflow/local/lib/python2.7/site-packages/tensor2tensor/data_generators/text_encoder.py", line 323, in bisect
other_subtokenizer = bisect(min_val, present_count - 1)
File "/home/feigao/tensorflow/local/lib/python2.7/site-packages/tensor2tensor/data_generators/text_encoder.py", line 323, in bisect
other_subtokenizer = bisect(min_val, present_count - 1)
File "/home/feigao/tensorflow/local/lib/python2.7/site-packages/tensor2tensor/data_generators/text_encoder.py", line 323, in bisect
other_subtokenizer = bisect(min_val, present_count - 1)
File "/home/feigao/tensorflow/local/lib/python2.7/site-packages/tensor2tensor/data_generators/text_encoder.py", line 323, in bisect
other_subtokenizer = bisect(min_val, present_count - 1)
File "/home/feigao/tensorflow/local/lib/python2.7/site-packages/tensor2tensor/data_generators/text_encoder.py", line 324, in bisect
if (abs(other_subtokenizer.vocab_size - target_size) <
AttributeError: 'NoneType' object has no attribute 'vocab_size'
Yes, sorry, there is a bug in data_generators/text_encoder.py. Lines 324-327 have an extra indent level that shouldn't be there. They should be outdented by 2 spaces and that will solve the problem. I will put in a PR to fix this ASAP.