def __init__(self, cell, location_softmax, pointing_output,
input_size, decoder_inputs=None,
trainable=True, name=None, **kwargs):
"""Initializes a new PointingSoftmaxDecoder instance.
See the class documentation for the escription of all the arguments.
"""
super(PointingSoftmaxDecoder, self).__init__(
trainable=trainable, name=name, **kwargs)
self._cell = cell
self._loc = location_softmax
self._out = pointing_output
self._inp_size = input_size
if decoder_inputs is not None:
tensors = tf.transpose(decoder_inputs, [1, 0, 2])
dtype = tensors.dtype
size = tf.shape(tensors)[0]
element_shape = tensors.get_shape()[1:]
tensor_array = tf.TensorArray(dtype=dtype, size=size, element_shape=element_shape)
decoder_inputs = tensor_array.unstack(tensors)
self._inputs_ta = decoder_inputs
# infer the batch/location size from the `states` tensor
# of the attention layer of the injected location softmax.
states = self._loc.attention.states
self._batch_size = utils.get_dimension(states, 0)
self._loc_size = utils.get_dimension(states, 1)
评论列表
文章目录