Why does TensorFlow example fail when increasing batch size?

后端 未结 4 619
旧时难觅i
旧时难觅i 2020-12-03 05:25

I was looking at the Tensorflow MNIST example for beginners and found that in this part:

for i in range(1000):
  batch_xs, batch_ys = mnist.train.next_batch(1         


        
4条回答
  •  温柔的废话
    2020-12-03 06:08

    Nan occurs when 0*log(0) occurs:

    replace:

    cross_entropy = -tf.reduce_sum(y_*tf.log(y))
    

    with:

    cross_entropy = -tf.reduce_sum(y_*tf.log(y + 1e-10))
    

提交回复
热议问题