def cross_entropy_seq(logits, target_seqs, batch_size=1, num_steps=None):
 loss = tf.nn.seq2seq.sequence_loss_by_example([logits], [tf.reshape(target_seqs, [(-1)])], [tf.ones([(batch_size * num_steps)])])
 cost = (tf.reduce_sum(loss) / batch_size)
 return cost

def cross_entropy_seq ( logits , target_seqs , batch_size = 1 , num_steps = None ) : loss = tf . nn . seq2seq . sequence_loss_by_example ( [ logits ] , [ tf . reshape ( target_seqs , [ ( - 1 ) ] ) ] , [ tf . ones ( [ ( batch_size * num_steps ) ] ) ] ) cost = ( tf . reduce_sum ( loss ) / batch_size ) return cost
returns the expression of cross-entropy of two sequences .