Advertisement
Guest User

nmt_model.py

a guest
Apr 4th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. """Defines a small unidirectional LSTM encoder-decoder model."""
  2.  
  3. import tensorflow as tf
  4. import opennmt as onmt
  5.  
  6. def model():
  7.   return onmt.models.SequenceToSequence(
  8.       source_inputter=onmt.inputters.WordEmbedder(
  9.           vocabulary_file_key="source_words_vocabulary",
  10.           embedding_size=512),
  11.       target_inputter=onmt.inputters.WordEmbedder(
  12.           vocabulary_file_key="target_words_vocabulary",
  13.           embedding_size=512),
  14.       encoder=onmt.encoders.BidirectionalRNNEncoder(
  15.           num_layers=4,
  16.           num_units=1024,
  17.           cell_class=tf.contrib.rnn.LSTMCell,
  18.           dropout=0.3,
  19.           residual_connections=False),
  20.       decoder=onmt.decoders.MultiAttentionalRNNDecoder(
  21.           num_layers=4,
  22.           num_units=1024,
  23.           attention_layers=[1],
  24.           attention_mechanism_class=tf.contrib.seq2seq.LuongAttention,
  25.           cell_class=tf.contrib.rnn.LSTMCell,
  26.           dropout=0.3,
  27.           residual_connections=False))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement