I am new to machine learning and neural network. I am trying to do text classification using neural network from scratch. In my dataset there are 7500 documents each labeled with one of seven classes. There are about 5800 unique words. I am using one hidden layer with 4000 neurons. Using sigmoid for activation function. Learning rate=0.1,No dropout.
During training After about 2 to 3 epochs,A warning is displayed :
RuntimeWarning: overflow encountered in exp.The resultant output list appears as:
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 4.11701866e-10] for every input except 4.11701866e-10.
sigmoid function:
def sigmoid(x):
output = 1/(1+np.exp(-x))
return output
def sigmoid_output_to_derivative(output):
return output*(1-output)
How to fix this?Can i use different activation function?
Here is my full code: https://gist.github.com/coding37/a5705142fe1943b93a8cef4988b3ba5f