W3cubDocs

/TensorFlow Python

tf.contrib.legacy_seq2seq.sequence_loss(logits, targets, weights, average_across_timesteps=True, average_across_batch=True, softmax_loss_function=None, name=None)

tf.contrib.legacy_seq2seq.sequence_loss(logits, targets, weights, average_across_timesteps=True, average_across_batch=True, softmax_loss_function=None, name=None)

Weighted cross-entropy loss for a sequence of logits, batch-collapsed.

Args:

  • logits: List of 2D Tensors of shape [batch_size x num_decoder_symbols].
  • targets: List of 1D batch-sized int32 Tensors of the same length as logits.
  • weights: List of 1D batch-sized float-Tensors of the same length as logits.
  • average_across_timesteps: If set, divide the returned cost by the total label weight.
  • average_across_batch: If set, divide the returned cost by the batch size.
  • softmax_loss_function: Function (inputs-batch, labels-batch) -> loss-batch to be used instead of the standard softmax (the default if this is None).
  • name: Optional name for this operation, defaults to "sequence_loss".

Returns:

A scalar float Tensor: The average log-perplexity per symbol (weighted).

Raises:

  • ValueError: If len(logits) is different from len(targets) or len(weights).

Defined in tensorflow/contrib/legacy_seq2seq/python/ops/seq2seq.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/legacy_seq2seq/sequence_loss