Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Training Cost NAN #27

Open
jiangqy opened this issue Apr 17, 2016 · 11 comments
Open

Training Cost NAN #27

jiangqy opened this issue Apr 17, 2016 · 11 comments

Comments

@jiangqy
Copy link

jiangqy commented Apr 17, 2016

Hi, I would like to train AlexNet on ImageNet. While after 20 iterations, training cost becomes nan.
Here are the details:

d8yaw cmo5 ynyr t_ krs

Should I set a smaller learning rate? Could you give me some suggestions?

Thank you~

@hma02
Copy link
Contributor

hma02 commented Apr 22, 2016

@jiangqy
What is your batch size and current learning rate?

@heipangpang
Copy link

I have met the same problem, and my batch size is 256, learning rate is 0.01. Do you have any ideas?

@jiangqy
Copy link
Author

jiangqy commented May 31, 2016

@hma02 My batch size is 256 and learning rate is 0.01, too.

@hma02
Copy link
Contributor

hma02 commented May 31, 2016

@jiangqy @heipangpang
Looks like you are running the single GPU train.py, then the problem is not related to weight exchanging.

The cost should be around 6.9 initially.

The unbounded cost value maybe caused by gradient explosion. I got into similar situations when initializing a deep network with arrays of large variance and mean. Too large learning rates and batch sizes may result in strong gradient zigzag as well.

Also do check the input images when loading them
to see if they are preprocessed correctly and correspond to loaded labels
You can show them using similar tricks as here. Try using a stack of image_means as input data

@heipangpang
Copy link

@hma02
I will try it. Thank you very much.

@heipangpang
Copy link

@hma02
When I check the output of every layer, I found that for the layer_input, I got a zero matrix which may be the problem why I such a large training loss.

@hma02
Copy link
Contributor

hma02 commented Jun 2, 2016

@heipangpang
Yes, this probably is the reason you got large cost. Make sure you set use_data_layer to False in config.yaml. Then the layer_input should be equal to x as shown here, which is the input batch. If x is a zero matrix, there's something wrong with the preprocessed image batches.

@heipangpang
Copy link

@hma02
But when I load the batches hand by hand in python, it seems that I can get the correct results.
Thank you very much.

@heipangpang
Copy link

@hma02
I am getting the correct results now, thank you very much.

@liaocs2008
Copy link

I had the same problem here. If "para_load" is set False, I could train it normally. But I think one of great contributions of this work is the parallel loading right?

@Magotraa
Copy link

@heipangpang
Can you please share, what change exactly made it possible for you to get correct results.

As you wrote
"I am getting the correct results now, thank you very much."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants