Sha256: dd423ee5f7ce422ea107955b81c9afee41211c025a3623747b3ade6900dfbcfb

Contents?: true

Size: 439 Bytes

Versions: 1

Compression:

Stored size: 439 Bytes

Contents

module TensorFlow
  module Keras
    module Losses
      class SparseCategoricalCrossentropy
        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
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tensorflow-0.2.0 lib/tensorflow/keras/losses/sparse_categorical_crossentropy.rb