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

Keras Dense层输入未被展平

这是我的测试代码: from keras import…

无法将分类变量输入随机森林

我有10个分类变量和3个数值变量。我在分割后直接将它们…

如何在Keras中对每个输出应用Sigmoid函数?

这是我代码的一部分。 model = Sequenti…

如何选择类概率的最佳阈值?

我的神经网络输出是一个用于多标签分类的预测类概率表: …

在Keras中使用深度学习得到不同的结果

我按照一个教程使用Keras中的深度神经网络进行文本分…

‘MatMul’操作的输入’b’类型为float32,与参数’a’的类型float64不匹配

我写了一个简单的TensorFlow代码,但不断遇到T…

发表回复

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