Class BasicDecoder
Inherits From: Decoder
Defined in tensorflow/contrib/seq2seq/python/ops/basic_decoder.py
.
Basic sampling decoder.
__init__
__init__(
cell,
helper,
initial_state,
output_layer=None
)
Initialize BasicDecoder.
Args:
cell
: AnRNNCell
instance.helper
: AHelper
instance.initial_state
: A (possibly nested tuple of...) tensors and TensorArrays. The initial state of the RNNCell.output_layer
: (Optional) An instance oftf.layers.Layer
, i.e.,tf.layers.Dense
. Optional layer to apply to the RNN output prior to storing the result or sampling.
Raises:
TypeError
: ifcell
,helper
oroutput_layer
have an incorrect type.
Properties
batch_size
The batch size of input values.
output_dtype
A (possibly nested tuple of...) dtype[s].
output_size
A (possibly nested tuple of...) integer[s] or TensorShape
object[s].
tracks_own_finished
Describes whether the Decoder keeps track of finished states.
Most decoders will emit a true/false finished
value independently
at each time step. In this case, the dynamic_decode
function keeps track
of which batch entries are already finished, and performs a logical OR to
insert new batches to the finished set.
Some decoders, however, shuffle batches / beams between time steps and
dynamic_decode
will mix up the finished state across these entries because
it does not track the reshuffle across time steps. In this case, it is
up to the decoder to declare that it will keep track of its own finished
state by setting this property to True
.
Returns:
Python bool.
Methods
tf.contrib.seq2seq.BasicDecoder.finalize
finalize(
outputs,
final_state,
sequence_lengths
)
tf.contrib.seq2seq.BasicDecoder.initialize
initialize(name=None)
Initialize the decoder.
Args:
name
: Name scope for any created operations.
Returns:
(finished, first_inputs, initial_state)
.
tf.contrib.seq2seq.BasicDecoder.step
step(
time,
inputs,
state,
name=None
)
Perform a decoding step.
Args:
time
: scalarint32
tensor.inputs
: A (structure of) input tensors.state
: A (structure of) state tensors and TensorArrays.name
: Name scope for any created operations.
Returns:
(outputs, next_state, next_inputs, finished)
.