LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 223|回复: 0

构建神经网络

[复制链接]
发表于 2024-1-4 19:11:49 | 显示全部楼层 |阅读模式
本帖最后由 xhz 于 01-04 编辑

构建神经网络

在本节中,让我们使用NeuroLab软件包在Python中构建一些神经网络。

基于感知器的分类器感知器是ANN的基石。 如果您想了解更多关于Perceptron的信息,可以点击链接 - artificial_neural_network

以下是逐步执行Python代码,用于构建基于感知器的简单神经网络分类器 -
  
如下所示导入必要的软件包 -

import matplotlib.pyplot as plt
import neurolab as nl

请注意,这是一个监督学习的例子,因此您也必须提供目标值。

input = [[0, 0], [0, 1], [1, 0], [1, 1]]
target = [[0], [0], [0], [1]]
Python
用2个输入和1个神经元创建网络 -
net = nl.net.newp([[0, 1],[0, 1]], 1)

现在,训练网络。 在这里使用Delta规则进行训练。

error_progress = net.train(input, target, epochs=100, show=10, lr=0.1)

接下来,可视化输出并绘制图表 -

plt.figure()
plt.plot(error_progress)
plt.xlabel('Number of epochs')
plt.ylabel('Training error')
plt.grid()
plt.show()

可以看到下图显示了使用错误度量标准的训练进度 -






//更多请阅读:https://www.yiibai.com/ai_with_p ... eural_networks.html




您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表