简体   繁体   English

人工神经网络训练与测试

[英]Artificial Neural Network Training and Testing

I'm trying to create an ANN that will solve a simple classification problem the example I am using is a degree classification so the input will be a percentage between 0-100 and the output will be one of five (1st, 2:1, 2:2...). 我正在尝试创建一个ANN,它将解决一个简单的分类问题,例如,我使用的示例是度分类,因此输入将是0-100之间的百分比,而输出将是五分之一(1st,2:1, 2:2 ...)。

Currently I have set up a neural network with three layers, 1 input neuron, 3 hidden neurons and 5 output neurons, I have managed to train the network using one input eg 60 and the output (1,0,0,0,0). 目前,我已经建立了一个具有三层的神经网络,即1个输入神经元,3个隐藏神经元和5个输出神经元,我设法使用一个输入(例如60和输出(1,0,0,0,0))训练网络。 I am unsure though how i would go about properly training the network for each input and output combination so that after training I would be able to input the percentage and the correct output neuron would be the number closest to 1. 我不确定如何为每种输入和输出组合正确地训练网络,以便在训练后我能够输入百分比,正确的输出神经元将是最接近1的数字。

The network uses standard feed forward and back propagation algorithms, random weights and the Sigmoid function. 该网络使用标准的前馈和后传算法,随机权重和Sigmoid函数。

I have a file which I was thinking would work with inputs 0-100 with the outputs inbetween: 我有一个文件,我认为该文件可以与输入0-100一起使用,而输出介于两者之间:

0 0
1, 0, 0, 0, 0 1,0,0,0,0

1 1个
1, 0, 0, 0, 0 1,0,0,0,0

..... .....

40 40
0, 1, 0, 0, 0 0、1、0、0、0

.... ....

100 100
0, 0, 0, 0, 1 0、0、0、0、1

Thanks 谢谢

I don't quite understand the function you are trying to learn, but it doesn't matter. 我不太了解您要学习的功能,但这并不重要。 The usual way to train an ANN is to use SGD (stochastic gradient descent) where backpropagation is used to compute the gradient for each example at a time. 训练ANN的常用方法是使用SGD(随机梯度下降),其中反向传播用于一次计算每个示例的梯度。 You just repeat looping this over all input examples until it has learned those examples. 您只需在所有输入示例上重复循环,直到了解了这些示例为止。

One thing you didn't mention is that you need a loss function. 您没有提到的一件事是您需要损失函数。 In your case, a simple mean squared error might be appropriate. 在您的情况下,可能需要一个简单的均方误差。

I suggest that you take a look at the classifer.py python script used for classification at this link - http://www.marekrei.com/blog/theano-tutorial/ The complete code for the above tutorial is available at this link - https://github.com/marekrei/theano-tutorial 我建议您在此链接上查看用于分类的classifer.py python脚本classifer.py : //www.marekrei.com/blog/theano-tutorial/此链接提供了上述教程的完整代码- https://github.com/marekrei/theano-tutorial

The classifier script at above link is meant for predicting whether the GDP per capita for a country is more than the average GDP. 上面链接的分类脚本用于预测一个国家的人均GDP是否高于平均GDP。 I, however, used the script for different kind of dataset. 但是,我将脚本用于其他类型的数据集。 I was able to successfully train neural networks in Theano using the above classifier script for classifying a speech sound as the letter "A" or "E". 使用上述分类器脚本,我可以成功地在Theano中训练神经网络,从而将语音分类为字母“ A”或“ E”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM