简体   繁体   English

如何计算神经网络的输出?

[英]How do I calculate output of a Neural Network?

I just started learning about ANNs about a week ago with no classical training.大约一周前,我刚刚开始学习人工神经网络,没有接受经典训练。 Just by watching videos and reading blogs/white papers, I've gotten this far.仅仅通过观看视频和阅读博客/白皮书,我已经走到了这一步。

I have a question about the final output of the ANN.我对 ANN 的最终输出有疑问。

Say for instance I was building a XOR with two input node, 3 nodes in one hidden layer and one node in the output layer.举例来说,我正在构建一个具有两个输入节点的 XOR,一个隐藏层中的 3 个节点和输出层中的一个节点。 A 2 x 3 x 1.一个 2 x 3 x 1。

First I would like to make sure I have the first part right.首先,我想确保我的第一部分是正确的。

So each node has a weight associated with it for each node in the hidden layer, if you have 5 nodes in the hidden layer, the input node would calculate it's input and multiply it by a weight associated with each node in the hidden layer.因此,对于隐藏层中的每个节点,每个节点都有一个与其关联的权重,如果隐藏层中有 5 个节点,则输入节点将计算其输入并将其乘以与隐藏层中每个节点关联的权重。

So to calculate the sigmoid for the first node, you would take all the inputs and multiply it by the weight (no + for a bias) and apply the sigmoid function for the sum of the inputs * weights.因此,要计算第一个节点的 sigmoid,您将获取所有输入并将其乘以权重(没有 + 表示偏差),然后将 sigmoid 函数应用于输入 * 权重的总和。 Then we would squash that value with a sigmoid and get 0.5866175789173301.然后我们将用 sigmoid 压缩该值并得到 0.5866175789173301。

Essentially, it would be, (1 x .25) + (1 x .10) = .35.本质上,它是 (1 x .25) + (1 x .10) = .35。

Now, that I just do this three times for each node and get 3 squashed numbers.现在,我只为每个节点执行此操作 3 次,并得到 3 个压扁的数字。

  // (input1 * HiddenNode(x)Weight) + (input2 * HiddenNode(x)Weight)
  activationFunction((1 * .25) + (1 * .10)) // 0.5866175789173301
  activationFunction((0 * .40) + (1 * .60)) // 0.6456563062257954
  activationFunction((1 * .20) + (0 * .80)) // 0.549833997312478

Now from what I understand, I again sum & squash those answers:现在根据我的理解,我再次总结并压缩这些答案:

  activationFunction(hidden1 + hidden2 + hidden3) // 0.8559569515861635

Do I have it correct so far?到目前为止我是否正确?

My question is, if you're feeding in two scaled numbers to predict grades, 89 & 6.5 = (grade/hours of sleep)我的问题是,如果你用两个比例数字来预测成绩,89 和 6.5 =(成绩/睡眠小时数)

How would you calculate the output from .8559 to a number like 93 and calculate the error on that value?您将如何计算从 .8559 到 93 之类的数字的输出并计算该值的误差? Am I missing anything besides a bias?除了偏见,我还缺少什么吗?

If I entered in the percent of change for the last 3 stock price changes, and I wanted it to guess the fourth price, how would I convert an answer like this:如果我输入了最近 3 次股价变动的变动百分比,并且我想让它猜测第四个价格,我将如何转换这样的答案:

 activationFunction(hidden1 + hidden2 + hidden3) // 0.8559569515861635

to an answer to like .10 (percent change in stock price) or any other real world answer? 0.10(股票价格的百分比变化)或任何其他现实世界的答案?

Thanks in advance!提前致谢!

Unlike people mentioned.不像人们提到的。 Inputs should not be binary.输入不应二进制。 They should be between a certain range ( 0,1 for sigmoid, -1,1 for TanH).它们应该在某个范围之间(对于 sigmoid 为0,1 ,对于 TanH 为-1,1 )。

On the first part you are exactly right if you don't account for bias.在第一部分,如果您不考虑偏见,您就完全正确。

// Completely right, each hidden node gets input from 2 input nodes
activationFunction((1 * .25) + (1 * .10)) // 0.5866175789173301
activationFunction((0 * .40) + (1 * .60)) // 0.6456563062257954
activationFunction((1 * .20) + (0 * .80)) // 0.549833997312478

// However, all the hidden nodes are connected the output node
output = activationFunction((0.59 * weight1) + (0.64 * weight2) + (0.55 * weight3))

Always keep in mind that nodes can only be connected to other nodes by connections, which always have a weight.永远记住,节点只能通过连接连接到其他节点,连接总是有权重的。

My question is, if you're feeding in two scaled numbers to predict grades, 89 & 6.5 = (grade/hours of sleep)我的问题是,如果你用两个比例数字来预测成绩,89 和 6.5 =(成绩/睡眠小时数)

First you scale the inputs (read more here ):首先,您缩放输入( 在此处阅读更多内容):

89 > 0.89
6.5 > 6.4 / 24 = 0.27

So if the new grade you got was 100, and your output was 0.8559 then the error on your output node is 1.00 - 0.8559 = 0.1441 .因此,如果您获得的新成绩是 100,而您的输出是0.8559那么您的输出节点上的错误是1.00 - 0.8559 = 0.1441 Then you backpropagate this through the network, but i'm not the right one to explain that for you.然后你通过网络反向传播这一点,但我不适合为你解释这一点。

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

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