W3cubDocs

/TensorFlow Python

tf.contrib.seq2seq.attention_decoder_fn_train(encoder_state, attention_keys, attention_values, attention_score_fn, attention_construct_fn, name=None)

tf.contrib.seq2seq.attention_decoder_fn_train(encoder_state, attention_keys, attention_values, attention_score_fn, attention_construct_fn, name=None)

Attentional decoder function for dynamic_rnn_decoder during training.

The attention_decoder_fn_train is a training function for an attention-based sequence-to-sequence model. It should be used when dynamic_rnn_decoder is in the training mode.

The attention_decoder_fn_train is called with a set of the user arguments and returns the decoder_fn, which can be passed to the dynamic_rnn_decoder, such that

dynamic_fn_train = attention_decoder_fn_train(encoder_state)
outputs_train, state_train = dynamic_rnn_decoder(
    decoder_fn=dynamic_fn_train, ...)

Further usage can be found in the kernel_tests/seq2seq_test.py.

Args:

  • encoder_state: The encoded state to initialize the dynamic_rnn_decoder.
  • attention_keys: to be compared with target states.
  • attention_values: to be used to construct context vectors.
  • attention_score_fn: to compute similarity between key and target states.
  • attention_construct_fn: to build attention states.
  • name: (default: None) NameScope for the decoder function; defaults to "simple_decoder_fn_train"

Returns:

A decoder function with the required interface of dynamic_rnn_decoder intended for training.

Defined in tensorflow/contrib/seq2seq/python/ops/attention_decoder_fn.py.

© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/contrib/seq2seq/attention_decoder_fn_train