title: In Tensorflow, what is the difference between sampled_softmax_loss and softmax_cross_entropy_with_logits
body: <p>In tensorflow, there are methods called <a href="https://www.tensorflow.org/versions/master/api_docs/python/tf/nn/softmax_cross_entropy_with_logits" rel="nofollow noreferrer"><code>softmax_cross_entropy_with_logits</code></a> and <a href="https://www.tensorflow.org/versions/master/api_docs/python/tf/nn/sampled_softmax_loss" rel="nofollow noreferrer"><code>sampled_softmax_loss</code></a>.</p>
  
  <p>I read the tensorflow document and searched google for more information but I couldn't find the difference. It looks like to me both calculates the loss using softmax function.</p>
  
  <h3>Using <code>sampled_softmax_loss</code> to calculate the loss</h3>
  
  <pre><code>loss = tf.reduce_mean(tf.nn.sampled_softmax_loss(...))
  </code></pre>
  
  <h3>Using <code>softmax_cross_entropy_with_logits</code> to calculate the loss</h3>
  
  <pre><code>loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(P, Q))
  </code></pre>
  
  <p>To me, calculating softmax loss is same as calculating softmaxed cross entropy (e.g. <code>cross_entropy(softmax(train_x))</code>)</p>
  
  <p>Could somebody tell me the why there is two different methods and which method should I use in which case?</p>