python - 神经网络 - 输出收敛于 0,python

标签 python machine-learning neural-network backpropagation

我正在尝试使用简单的反向传播和单热编码将多层神经网络中的 2D 数据分为 3 类。在我将增量学习更改为批量学习后,我的输出收敛到 0 ([0,0,0]),主要是如果我使用更多数据或更高的学习速度。我不知道我是否必须衍生出其他东西,或者我是否在代码中犯了一些错误。

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

最佳答案

我会尝试一些玩具示例,我确定 NN 将如何表现并调试我的代码。如果我确定我的代码是有效的 NN 并且我仍然没有得到好的结果,我会尝试更改 NN 的参数。但这可能相当耗时,因此我会选择一些更简单的机器学习技术,例如决策树不像神经网络那样是黑盒。使用决策树,您应该更容易、更快地找到解决方案。问题是你是否可以在神经网络以外的地方实现它......

关于python - 神经网络 - 输出收敛于 0,python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15948940/

相关文章:

python - Pandas 可以在 Google App Engine for Python 上运行吗?

java - 使程序针对不同的输入运行网站

machine-learning - Torch - 神经网络的大输入和输出

machine-learning - 为什么word2vec不使用正则化?

machine-learning - 预训练卷积神经网络的微调

algorithm - 反向传播可以同时训练两个异或问题吗?

python - 在 Python 中解析大型伪 csv 日志文件

python - 禁用 argparse 选择消息

python - xgboost 中的多类分类(python)

matlab - 图像大小调整和裁剪的顺序重要吗?