**def sparse_softmax_cross_entropy_with_logits(_sentinel=None, # pylint: disable=invalid-name
labels=None,logits=None,name=None):**
labels是非稀疏的,例如稀疏矩阵为
[[ 1. 0. 0.]
[ 0. 1. 0.]
[ 0. 0. 1.]]
shape:[3,3]
转化为非稀疏矩阵为:[0 1 2], shape:[3]
转化方式:yy_=tf.arg_max(y_,1)
A common use case is to have logits of shape `[batch_size, num_classes]` and
labels of shape `[batch_size]`. But higher dimensions are supported.
logits是未归一化的概率,Unscaled log probabilities of shape
`[d_0, d_1, ..., d_{r-1}, num_classes]` and dtype `float32` or `float64`.
name: A name for the operation (optional).
yy_=tf.arg_max(y_,1)
cross_entropy2_step1=tf.nn.sparse_softmax_cross_entropy_with_logits(labels=yy_,logits=logits)
cross_entropy2_step2=tf.reduce_sum(cross_entropy2_step1)
tf.nn.softmax_cross_entropy_with_logits与其主要的区别为labels,这里的
yy_=y_
cross_entropy2_step1=tf.nn.sparse_softmax_cross_entropy_with_logits(labels=yy_,logits=logits)
cross_entropy2_step2=tf.reduce_sum(cross_entropy2_step1)2_step1)
tf.nn.sparse_softmax_cross_entropy_with_logits
最新推荐文章于 2021-04-15 21:19:39 发布