-
Notifications
You must be signed in to change notification settings - Fork 33
/
t2t_decoder.py
43 lines (35 loc) · 1.01 KB
/
t2t_decoder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Decode."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensor2tensor.bin import t2t_decoder
from tensor2tensor.models import transformer
import problems
import tensorflow as tf
import decoding
from tensor2tensor.utils import registry
flags = tf.flags
FLAGS = flags.FLAGS
@registry.register_hparams
def transformer_tall9():
hparams = transformer.transformer_big()
hparams.hidden_size = 768
hparams.filter_size = 3072
hparams.num_hidden_layers = 9
hparams.num_heads = 12
return hparams
@registry.register_hparams
def transformer_tall_18_18():
hparams = transformer_tall9()
hparams.num_encoder_layers = 18
hparams.num_decoder_layers = 18
return hparams
if __name__ == '__main__':
tf.logging.set_verbosity(tf.logging.INFO)
# tf.app.run(t2t_decoder.main)
decoding.t2t_decoder(
FLAGS.problem,
FLAGS.data_dir,
FLAGS.decode_from_file,
FLAGS.decode_to_file,
FLAGS.checkpoint_path or FLAGS.output_dir)