Reputation: 4319
I was trying to create a convolutional NN for house numbers images in tensorflow http://ufldl.stanford.edu/housenumbers/
I am getting cost as nan right in the first step when I am running my code. Here is the link to the github where I have put in my code https://github.com/ibnipun10/TensorFlow/blob/master/convhouseNumbers.ipynb
Please let me know where I am making mistake
Upvotes: 3
Views: 1230
Reputation: 27060
The loss is NaN because the gradient is just exploded.
Your code looks ok, but your learning rate is high. Try with a lower learning rate (like 1e-2
or 1e-3
) and see if the gradient still explode.
In addiction, I don't know if the images you're using in training have just been converted to float values and scaled in order to have zero mean and unit norm, but usually this is a step needed when working with images that helps to avoid gradient explosions.
Tensorflow have a function for that: tf.image.per_image_whitening
Upvotes: 5