2013-04-11 88 views
1

我想使用簡單的反向傳播和單熱編碼在多層神經網絡中將2D數據分爲3類。在將增量學習更改爲批量學習後,我的輸出收斂到0([0,0,0]),主要是如果我使用更多數據或更高的學習速度。我不知道我是否需要衍生其他東西,或者如果我在代碼中犯了一些錯誤。神經網絡 - 輸出收斂到0,python

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])] 

回答

0

我想嘗試一些玩具的例子,我確定NN會如何表現和調試我的代碼。如果我確定我的代碼是有效的NN,並且我仍然沒有得到好的結果,我會嘗試更改NN的參數。但它可以花費相當長的時間,因此我會選擇一些更簡單的ML技術,例如決策樹不是黑箱而是NN。通過決策樹,您可以更輕鬆,更快地找到解決方案。問題是你是否可以在NN以外的地方實現它...