Python> assert not np.isnan (loss_value),'Model diverged with loss = NaN'

Operating environment


Ubuntu 14.04 LTS desktop amd64
GeForce GTX 750 Ti
ASRock Z170M Pro4S [Intel Z170chipset]
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v7.5
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.

I'm learning a deep learning framework called TensorFlow.

Play down TensorFlow! 4-1. Convolutional Neural Networks http://blog.brainpad.co.jp/entry/2016/04/22/170000

I'm reading a Tutorial that handles CIFAR-10 datasets.

The following assert not np.isnan () description in cifar10_train.py was undigested.

cifar10_train.py


...
    for step in xrange(FLAGS.max_steps):
      start_time = time.time()
      _, loss_value = sess.run([train_op, loss])
      duration = time.time() - start_time

      assert not np.isnan(loss_value), 'Model diverged with loss = NaN'
...

It seems to make an error when loss_value becomes NaN.

https://docs.scipy.org/doc/numpy/reference/generated/numpy.isnan.html http://docs.python.jp/2.4/ref/assert.html

Recommended Posts

Python> assert not np.isnan (loss_value),'Model diverged with loss = NaN'
[Python] Super easy test with assert statement
Python log is not output with docker-compose up
[Python] Expression (1,2) does not make tuples with parentheses