Adaline神经元训练

我想了解Adaline神经元的工作原理。

我用VB.NET编写了一个示例代码,我想训练一个神经元来实现AND或OR功能。

这是我的代码:

    Dim Valid As Boolean    Dim c As Integer = 0    Do        Valid = True        c += 1        For i As Integer = 0 To ListBox1.Items.Count - 1            Dim s() As String = Microsoft.VisualBasic.Split(ListBox1.Items(i), " ")            Dim y As Single = (W(1) * CInt(s(0)) + W(2) * CInt(s(1)))' + W(3) * 1)            W(1) += Alpha * CSng(CInt(s(2)) - y) * CSng(CInt(s(0)))            W(2) += Alpha * CSng(CInt(s(2)) - y) * CSng(CInt(s(1)))            'W(3) += Alpha * CSng(CInt(s(2)) - y) * 1.0        Next        For i As Integer = 0 To ListBox1.Items.Count - 1            Dim s() As String = Microsoft.VisualBasic.Split(ListBox1.Items(i), " ")            Dim y As Single = (W(1) * CInt(s(0)) + W(2) * CInt(s(1)))' + W(3) * 1)            If CInt(s(2)) = 1 Then                If y < 1 Then                    Valid = False                End If            Else                If y >= 1 Then                    Valid = False                End If            End If        Next    Loop Until ((Valid) Or (c > 100000))    If c > 10000 Then        MsgBox("I Can't Learn!", MsgBoxStyle.Exclamation)    End If

我尝试了有偏置和无偏置的情况。(如果你从注释部分移除注释标记,将会为神经元添加偏置)

我还尝试了这些训练集来训练AND和OR功能:

-1 -1 -1-1 1 -11 -1 -11 1 10 0 00 1 01 0 01 1 10 0 00 1 11 0 11 1 1-1 -1 -1-1 1 11 -1 11 1 1

但神经元无法用这些训练集进行训练…

我该如何解决这个问题?


回答:

问题是:我的硬限制函数将输出改为1,但它应该在0时改变答案。

这是修改后的代码部分:

        If CInt(s(2)) = 1 Then            If y < 0 Then                Valid = False            End If        Else            If y >= 0 Then                Valid = False            End If

我尝试启用偏置后,成功训练了AND和OR功能。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

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