reference : https://www.zhihu.com/question/52242037/answer/184101547

 

问题:使用tensorflow lenet5做minst识别,使用如下损失函数,在训练几轮后loss出现nan

loss = tf.reduce_mean(-tf.reduce_sum(self.y * tf.log(output), reduction_indices=1))

tensorflow识别minst出现loss nan情况

 

解决:当预测出现0时tf.log(0)无意义,出现nan;可在输出项增加微小的项

loss = tf.reduce_mean(-tf.reduce_sum(self.y * tf.log(output+1e-10), reduction_indices=1))

 

 

相关文章:

  • 2021-06-20
  • 2022-01-03
  • 2021-08-06
  • 2022-12-23
  • 2021-05-11
  • 2021-04-07
  • 2021-07-26
  • 2022-12-23
猜你喜欢
  • 2021-11-03
  • 2022-12-23
  • 2021-09-16
  • 2021-10-21
  • 2021-12-03
  • 2022-12-23
相关资源
相似解决方案