Categorical Crossentropy源码分析
Categorical Crossentropy源码分析 Source: import tensorflow as tf import numpy as np sess = tf.InteractiveSession() print("--------output-----------") target = tf.constant([1., 0., 0., 0., 1., 0., 0., 0., 1.], shape=[3,3]) print("target: \n",target.eval()) output = tf.constant([.9, .05, .05, .05, .89, .06, .05, .01, .94], shape=[3,3]) print("output:\n",output.eval()) loss = tf.keras.backend.categorical_crossentropy(target, output) print("loss: \n",loss.eval()) # Output: [0.10536 0.11653 0.06188] 官方