python - In Tensorflow, what is the difference between sampled_softmax_loss and softmax_cross_entropy_with_logits -
in tensorflow, there methods called softmax_cross_entropy_with_logits , sampled_softmax_loss.
i read tensorflow document , searched google more information can't find difference. looks me both calculates loss using softmax function.
using sampled_softmax_loss calculate loss
loss = tf.reduce_mean(tf.nn.sampled_softmax_loss(...))
using softmax_cross_entropy_with_logits calculate loss
loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(p, q))
to me, calculating softmax loss same calculating softmaxed cross entropy (e.g. cross_entropy(softmax(train_x)))
could tell me why there 2 different methods , method should use in case?
thank you.
if target vocabulary(or in other words amount of classes want predict) big, hard use regular softmax, because have calculate probability every word in dictionary. using sampled_softmax_loss
take in account subset v of vocabulary calculate loss.
sampled softmax makes sense if sample(our v) less vocabulary size. if vocabulary(amount of labels) small, there no point using sampled_softmax_loss
.
you can see implementation details in paper: http://arxiv.org/pdf/1412.2007v2.pdf
also can see example used - sequence sequence translation in example
Comments
Post a Comment