Perceptron在Erlang中训练后未能学习

我不认为我的问题是这个问题的重复,因为我的实现中已经包含了偏置项。

我尝试在Erlang中实现一个感知器及其训练,以识别线性斜率。问题在于它没有被正确训练。在50个周期后,它的猜测值仍然只有大约50%的正确率。

初始权重通过一个列表提供[X_weight, Y_Weight, Bias_weight],训练集通过另一个列表提供[X,Y,Desired_guess],其中X和Y是整数,Desired_guess如果坐标在线下方则为-1,如果在线上方则为1。

首先是计算新权重:

% 导出的起始子句% 输入是 - 一个感知器的输入值列表 ([X,Y,Bias]),对应输入的权重列表 [X_weight, Y_weight, Bias_weight],学习常数和误差 (Desired-Guess)train_perceptron([InputsH|InputsT], [WeightsH|WeightsT], Learning_constant, Error) ->    train_perceptron(InputsT, WeightsT, Learning_constant, Error,         [WeightsH + (Learning_constant * Error) * InputsH]).% 未导出的子句,由train_perceptron/4调用。这里也有一个调整后的新权重列表。% 当输入列表的尾部是空列表时,这是最后一个值,即偏置train_perceptron([InputsH|[]], [WeightsH|[]], Learning_constant, Error, Adjusted_weights) ->    train_perceptron([], [], Learning_constant, Error,        Adjusted_weights ++ [WeightsH + Learning_constant * Error]);% 正常情况,计算新权重并将它们添加到Adjusted_weights中train_perceptron([InputsH|InputsT], [WeightsH|WeightsT], Learning_constant,      Error, Adjusted_weights) ->    train_perceptron(InputsT, WeightsT,Learning_constant, Error,     Adjusted_weights ++ [WeightsH + (Learning_constant * Error) * InputsH]);% 基础情况,列表为空,没有更多要做的。返回Adjusted_weightstrain_perceptron([], [],_, _, Adjusted_weights) ->    Adjusted_weights.

这是调用train_perceptron函数的函数

line_trainer(Weights,[],_) ->     Weights;line_trainer(Weights, [{X,Y,Desired}|TST], Learning_constant)->     Bias = 1,     Error = Desired - feedforward([X,Y,Bias],Weights),     Adjusted_weights = train_perceptron([X,Y,Bias], Weights, Learning_constant, Error),     line_trainer(Adjusted_weights, TST, Learning_constant).

一个解决方案可能是,如果有人为这种类型的函数提供一个训练集,包括三个初始权重和每个周期的输出。这可以帮助我自己调试这个问题。


回答:

这实际上是有效的。我提供的训练集太小了。使用更大的训练集和大约20个周期,全局误差收敛到0。

Related Posts

L1-L2正则化的不同系数

我想对网络的权重同时应用L1和L2正则化。然而,我找不…

使用scikit-learn的无监督方法将列表分类成不同组别,有没有办法?

我有一系列实例,每个实例都有一份列表,代表它所遵循的不…

f1_score metric in lightgbm

我想使用自定义指标f1_score来训练一个lgb模型…

通过相关系数矩阵进行特征选择

我在测试不同的算法时,如逻辑回归、高斯朴素贝叶斯、随机…

可以将机器学习库用于流式输入和输出吗?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

在TensorFlow中,queue.dequeue_up_to()方法的用途是什么?

我对这个方法感到非常困惑,特别是当我发现这个令人费解的…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注