简体   繁体   中英

Neural network - output is converging to 0, python

I am trying to classify 2D data in to 3 classes in multy-layer neural network using simple back-propagation and one-hot encoding. After I changed incremental learning to batch learning my output is converging to 0 ( [0,0,0] ), mostly if I use more data or higher learning speed. I don't know if I have to derivate something else, or if I made some bugs in code.

for each epoch: #pseudocode
    for each input:
        caluclate hiden neurons activations (logsig)
        calculate output neurons activations (logsig)

        #error propagation   
        for i in range(3):  
            error = (desired_out[i] - aktivations_out[i])
            error_out[i] = error * deriv_logsig(aktivations_out[i])             
        t_weights_out = zip(*weights_out)           
        for i in range(hiden_neurons):  
            sum_error = sum(e*w for e, w in zip(error_out, t_weights_out[i]))               
            error_h[i] =  sum_error * deriv_logsig(input_out[i])

        #cumulate deltas             
        for i in range(len(weights_out)):                               
            delta_out[i] = [d + x * coef * error_out[i] for d, x in zip(delta_out[i],        input_out)]               
        for i in range(len(weights_h)):
            delta_h[i] = [d + x * coef * error_h[i] for d, x in zip(delta_h[i], input)]

    #batch learning after epoch
    for i in range(len(weights_out)):                               
            weights_out[i] = [w + delta for w, delta in zip(weights_out[i], delta_out[i])]
    for i in range(len(weights_h)):
            weights_h[i] = [w + delta for w, delta in zip(weights_h[i], delta_h[i])]

I'd try some toy-example where I'm sure how NN would behave and debug my code. If I'm sure that my code is valid NN and I'm still not getting good results I'd try to change parameters of NN. But it can by quite time consuming, therefore I'd go for some easier ML technique eg decision trees which are not blackbox as NN. With decision trees you should be easier and faster to find solution. Question is whether you can implement it in other than NN ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM