人工神经元是人工神经网络的一个节点,是自然神经元的简化模型。它的功能是将所有输入信号的线性组合转换成某种非线性函数,并将结果传输到一个输出端。人工神经元通过将一些神经元的输出与另一些神经元的输入连接起来,从而组合成网络。它们是理想神经计算机的基本要素。人工神经元和网络可用于各种实际应用,包括预测任务、模式识别和控制。它们可以通过简单处理器之间的相互作用执行复杂任务。人工神经元可以在生物环境中工作,是由人工元件和生物元件组成的生物混合神经元。然而,使用这种模型会引发严重的道德、社会和伦理问题。神经元公式的一般观点可表述如下:
y = ∑w * x + b
其中
y 是神经元的输出信号、
w - 输入的权重系数、
x - 输入值、
b - 偏差、
该公式描述了输入值乘以相应加权因子再加上偏置的线性组合。神经元根据所得值的符号对输入数据进行分类
本示例使用一个神经元和两个加权因子实现了一个简单的神经网络训练模型。输入数据被分为两组,然后根据目标值对两组进行训练。
训练过程持续 100,000 次迭代,期间根据预测误差更新权重。训练完成后,用新数据对模型进行测试,并绘制结果图。
从测试结果中我们可以看到,有两个点属于第一类,还有两个点属于第二类。让我们画一张图来直观地显示分类结果。
在这个例子中,我们从简单的层面分解了神经元的结构。它是构成卷积神经网络等更复杂神经网络的基本元素之一。
{"id": "9b063495-0913-48e2-9274-22fd17911ab3", "data": [{"showlegend": true, "mode": "markers", "xaxis": "x", "colorbar": {"y": 0.513888888888889, "title": {"text": ""}, "len": 0.9525371828521435, "x": 0.9934383202099737}, "name": "Class 0", "yaxis": "y", "legendgroup": "Class 0", "marker": {"symbol": "circle", "color": "rgba(0, 0, 255, 1.000)", "line": {"color": "rgba(0, 0, 0, 1)", "width": 1}, "size": 8}, "y": [0.67, 0.445, 0.633, 0.312], "type": "scatter", "x": [0.323, 0.45, 0.33, 0.22], "zaxis": null, "z": null, "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 4, "currentCount": 4}}}, {"showlegend": true, "mode": "markers", "xaxis": "x", "colorbar": {"y": 0.513888888888889, "title": {"text": ""}, "len": 0.9525371828521435, "x": 0.9934383202099737}, "name": "Class 1", "yaxis": "y", "legendgroup": "Class 1", "marker": {"symbol": "circle", "color": "rgba(255, 0, 0, 1.000)", "line": {"color": "rgba(0, 0, 0, 1)", "width": 1}, "size": 8}, "y": [0.112, 0.22, 0.35, 0.42], "type": "scatter", "x": [0.9, 0.76, 1.3123, 1.17], "zaxis": null, "z": null, "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 4, "currentCount": 4}}}, {"showlegend": true, "mode": "markers", "xaxis": "x", "colorbar": {"y": 0.513888888888889, "title": {"text": ""}, "len": 0.9525371828521435, "x": 0.9934383202099737}, "name": "Test", "yaxis": "y", "legendgroup": "Test", "marker": {"symbol": "circle", "color": "rgba(0, 128, 0, 1.000)", "line": {"color": "rgba(0, 0, 0, 1)", "width": 1}, "size": 8}, "y": [0.444, 0.43, 0.23, 0.3213], "type": "scatter", "x": [0.431, 0.6954, 0.12, 0.71], "zaxis": null, "z": null, "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 4, "currentCount": 4}}}, {"showlegend": true, "mode": "lines", "xaxis": "x", "colorbar": {"y": 0.513888888888889, "title": {"text": ""}, "len": 0.9525371828521435, "x": 0.9934383202099737}, "name": "Decision Boundary", "yaxis": "y", "legendgroup": "Decision Boundary", "line": {"color": "rgba(0, 0, 0, 1)", "shape": "linear", "dash": "solid", "width": 1}, "y": [0.7700990099009892, 0.7590656765676559, 0.7480323432343225, 0.7369990099009892, 0.725965676567656, 0.7149323432343226, 0.7038990099009893, 0.692865676567656, 0.6818323432343226, 0.6707990099009893, 0.659765676567656, 0.6487323432343226, 0.6376990099009893, 0.6266656765676559, 0.6156323432343226, 0.6045990099009892, 0.5935656765676559, 0.5825323432343226, 0.5714990099009892, 0.5604656765676559, 0.5494323432343226, 0.5383990099009892, 0.527365676567656, 0.5163323432343226, 0.5052990099009893, 0.4942656765676559, 0.48323234323432257, 0.47219900990098923, 0.46116567656765595, 0.4501323432343226, 0.43909900990098927, 0.42806567656765593, 0.4170323432343226, 0.40599900990098925, 0.3949656765676559, 0.38393234323432257, 0.37289900990098923, 0.36186567656765595, 0.3508323432343226, 0.33979900990098927, 0.32876567656765593, 0.3177323432343226, 0.30669900990098925, 0.2956656765676559, 0.2846323432343226, 0.2735990099009893, 0.26256567656765595, 0.2515323432343226, 0.24049900990098927, 0.22946567656765593, 0.2184323432343226, 0.20739900990098925, 0.1963656765676559, 0.18533234323432257, 0.17429900990098923, 0.1632656765676559, 0.15223234323432266, 0.14119900990098933, 0.13016567656765596, 0.11913234323432263, 0.10809900990098929, 0.09706567656765595, 0.08603234323432261, 0.07499900990098927, 0.06396567656765594, 0.05293234323432259, 0.04189900990098925, 0.03086567656765591, 0.019832343234322567, 0.008799009900989228, -0.0022343234323441118, -0.013267656765677453, -0.02430099009901079, -0.03533432343234402, -0.04636765676567736, -0.0574009900990107, -0.06843432343234404, -0.07946765676567738, -0.09050099009901072, -0.10153432343234406, -0.1125676567656774, -0.12360099009901074, -0.13463432343234408, -0.14566765676567742, -0.15670099009901076, -0.1677343234323441, -0.17876765676567744, -0.18980099009901077, -0.200834323432344, -0.21186765676567734, -0.22290099009901068, -0.23393432343234416, -0.2449676567656774, -0.25600099009901084, -0.26703432343234407, -0.2780676567656775, -0.28910099009901075, -0.300134323432344, -0.3111676567656774, -0.32220099009901065], "type": "scatter", "x": [0.22, 0.23103333333333334, 0.24206666666666668, 0.2531, 0.26413333333333333, 0.27516666666666667, 0.2862, 0.29723333333333335, 0.3082666666666667, 0.3193, 0.3303333333333333, 0.34136666666666665, 0.3524, 0.36343333333333333, 0.37446666666666667, 0.3855, 0.39653333333333335, 0.4075666666666667, 0.4186, 0.4296333333333333, 0.44066666666666665, 0.4517, 0.46273333333333333, 0.47376666666666667, 0.4848, 0.49583333333333335, 0.5068666666666667, 0.5179, 0.5289333333333334, 0.5399666666666667, 0.551, 0.5620333333333334, 0.5730666666666666, 0.5841, 0.5951333333333333, 0.6061666666666666, 0.6172, 0.6282333333333333, 0.6392666666666666, 0.6503, 0.6613333333333333, 0.6723666666666667, 0.6834, 0.6944333333333333, 0.7054666666666667, 0.7165, 0.7275333333333334, 0.7385666666666667, 0.7496, 0.7606333333333334, 0.7716666666666666, 0.7827, 0.7937333333333333, 0.8047666666666666, 0.8158, 0.8268333333333333, 0.8378666666666666, 0.8489, 0.8599333333333333, 0.8709666666666667, 0.882, 0.8930333333333333, 0.9040666666666667, 0.9151, 0.9261333333333334, 0.9371666666666667, 0.9482, 0.9592333333333334, 0.9702666666666667, 0.9813, 0.9923333333333333, 1.0033666666666667, 1.0144, 1.0254333333333334, 1.0364666666666666, 1.0475, 1.0585333333333333, 1.0695666666666668, 1.0806, 1.0916333333333332, 1.1026666666666667, 1.1137, 1.1247333333333334, 1.1357666666666666, 1.1468, 1.1578333333333333, 1.1688666666666667, 1.1799, 1.1909333333333334, 1.2019666666666666, 1.213, 1.2240333333333333, 1.2350666666666668, 1.2461, 1.2571333333333334, 1.2681666666666667, 1.2792, 1.2902333333333333, 1.3012666666666666, 1.3123], "zaxis": null, "z": null, "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 100, "currentCount": 100}}}], "config": {"showlegend": true, "xaxis": {"showticklabels": true, "gridwidth": 0.5, "tickvals": [0.25, 0.5, 0.75, 1, 1.25], "range": [0.08423100000000006, 1.3480690000000002], "domain": [0.08063575386410031, 0.9934383202099737], "mirror": false, "tickangle": 0, "showline": true, "ticktext": ["0.25", "0.50", "0.75", "1.00", "1.25"], "zeroline": false, "tickfont": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 11}, "zerolinecolor": "rgba(0, 0, 0, 1)", "anchor": "y", "visible": true, "ticks": "inside", "tickmode": "array", "linecolor": "rgba(0, 0, 0, 1)", "showgrid": true, "title": {"text": "", "font": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 15}}, "gridcolor": "rgba(0, 0, 0, 0.1)", "tickcolor": "rgb(0, 0, 0)", "type": "linear"}, "paper_bgcolor": "rgba(255, 255, 255, 1.000)", "annotations": [], "height": 400, "margin": {"l": 0, "b": 20, "r": 0, "t": 20}, "plot_bgcolor": "rgba(255, 255, 255, 1.000)", "yaxis": {"showticklabels": true, "gridwidth": 0.5, "tickvals": [-0.25, 0, 0.25, 0.5, 0.75], "range": [-0.35496999009901065, 0.8028680099009893], "domain": [0.03762029746281716, 0.9901574803149606], "mirror": false, "tickangle": 0, "showline": true, "ticktext": ["-0.25", "0.00", "0.25", "0.50", "0.75"], "zeroline": false, "tickfont": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 11}, "zerolinecolor": "rgba(0, 0, 0, 1)", "anchor": "x", "visible": true, "ticks": "inside", "tickmode": "array", "linecolor": "rgba(0, 0, 0, 1)", "showgrid": true, "title": {"text": "", "font": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 15}}, "gridcolor": "rgba(0, 0, 0, 0.1)", "tickcolor": "rgb(0, 0, 0)", "type": "linear"}, "legend": {"yanchor": "auto", "xanchor": "auto", "bordercolor": "rgba(0, 0, 0, 1)", "bgcolor": "rgba(255, 255, 255, 1.000)", "borderwidth": 1, "tracegroupgap": 0, "y": 1, "font": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 11}, "title": {"font": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 15}, "text": ""}, "traceorder": "normal", "x": 1}, "width": 774.828125}}