单项选择题
以下代码段中,计算平均交叉熵损失,正确的表达为______。
x = [1, 2, 0]
x_onehot = tf.one_hot(x, 3)
pred = np.array([[0.1, 0.2, 0.7], [0.1, 0.6, 0.3], [0.2, 0.6, 0.6]])
A、-tf.reduce_sum(x_onehot*tf.math.log(pred))/len(pred)
B、-tf.reduce_sum(x_onehot*tf.math.log(pred))
C、-tf.reduce_sum(np.array(x_onehot)*tf.math.log(pred))
D、-tf.reduce_sum(np.array(x_onehot)*tf.math.log(pred))/len(pred)