Computes softmax cross entropy cost and gradients to backpropagate. Inputs are the logits, not probabilities. Arguments: features: batch_size x num_classes matrix labels: batch_size x num_classes matrix The caller must ensure that each batch of labels represents a valid probability distribution.
(scope *Scope, features tf.Output, labels tf.Output)
| 24226 | // |
| 24227 | // Returns Per example loss (batch_size vector).backpropagated gradients (batch_size x num_classes matrix). |
| 24228 | func SoftmaxCrossEntropyWithLogits(scope *Scope, features tf.Output, labels tf.Output) (loss tf.Output, backprop tf.Output) { |
| 24229 | if scope.Err() != nil { |
| 24230 | return |
| 24231 | } |
| 24232 | opspec := tf.OpSpec{ |
| 24233 | Type: "SoftmaxCrossEntropyWithLogits", |
| 24234 | Input: []tf.Input{ |
| 24235 | features, labels, |
| 24236 | }, |
| 24237 | } |
| 24238 | op := scope.AddOperation(opspec) |
| 24239 | return op.Output(0), op.Output(1) |
| 24240 | } |
| 24241 | |
| 24242 | // Debugging/model interpretability outputs for each example. |
| 24243 | // |