How does one debug NaN values in TensorFlow?

后端 未结 9 1430
遥遥无期
遥遥无期 2020-12-23 09:07

I was running TensorFlow and I happen to have something yielding a NaN. I\'d like to know what it is but I do not know how to do this. The main issue is that in a \"normal\"

9条回答
  •  遥遥无期
    2020-12-23 09:51

    First of all, you need to check you input data properly. In most cases this is the reason. But not always, of course.

    I usually use Tensorboard to see whats happening while training. So you can see the values on each step with

    Z = tf.pow(Z, 2.0)    
    summary_z = tf.scalar_summary('z', Z) 
    #etc..
    summary_merge = tf.merge_all_summaries()
    #on each desired step save: 
        summary_str = sess.run(summary_merge)
        summary_writer.add_summary(summary_str, i)
    

    Also you can simply eval and print the current value:

     print(sess.run(Z))
    

提交回复
热议问题