class TensorFlow::Keras::Losses::SparseCategoricalCrossentropy

Public Instance Methods

call(target, output) click to toggle source
# File lib/tensorflow/keras/losses/sparse_categorical_crossentropy.rb, line 5
def call(target, output)
  output = Math.log(output)
  target = TensorFlow.cast(target, :int64)
  cost, _ = RawOps.sparse_softmax_cross_entropy_with_logits(features: output, labels: target)
  Math.reduce_sum(cost) / TensorFlow.cast(RawOps.size(input: cost), :float)
end