Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Neural network weights explode in linear unit

I am currently implementing a simple neural network and the backprop algorithm in Python with numpy. I have already tested my backprop method using central differences and the resulting gradient is equal.

However, the network fails to approximate a simple sine curve. The network hast one hidden layer (100 neurons) with tanh activation functions and a output layer with a linear activation function. Each unit hast also a bias input. The training is done by simple gradient descent with a learning rate of 0.2.

The problem arises from the gradient, which gets with every epoch larger, but I don't know why? Further, the problem is unchanged, if I decrease the learning rate.

EDIT: I have uploaded the code to pastebin: http://pastebin.com/R7tviZUJ

like image 828
Masala Avatar asked Jul 12 '26 13:07

Masala


1 Answers

There are two things you can try, maybe in combination:

  1. Use a smaller learning rate. If it is too high, you may be overshooting the minimum in the current direction by a lot, and so your weights will keep getting larger.

  2. Use smaller initial weights. This is related to the first item. A smaller learning rate would fix this as well.

like image 122
Jeffrey Sax Avatar answered Jul 15 '26 09:07

Jeffrey Sax



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!