如何将人工神经网络的输出转换为概率? [英] How to convert the output of an artificial neural network into probabilities?

查看:424
本文介绍了如何将人工神经网络的输出转换为概率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不久前,我已经了解了神经网络,并且我了解了ANN(尤其是通过反向传播学习的多层感知器)如何学会将事件分类为真还是假.

I've read about neural network a little while ago and I understand how an ANN (especially a multilayer perceptron that learns via backpropagation) can learn to classify an event as true or false.

我认为有两种方法:

1)您得到一个输出神经元.值> 0.5表示事件很可能为真,如果值< = 0.5则事件很可能为假.

1) You get one output neuron. It it's value is > 0.5 the events is likely true, if it's value is <=0.5 the event is likely to be false.

2)您得到两个输出神经元,如果第一个的值大于第二个的值,则该事件很可能是正确的,反之亦然.

2) You get two output neurons, if the value of the first is > than the value of the second the event is likely true and vice versa.

在这种情况下,ANN会告诉您某个事件是真是假.它并不能说明可能性有多大.

In these case, the ANN tells you if an event is likely true or likely false. It does not tell how likely it is.

是否有一种方法可以将该值转换为几率或直接从ANN中获得几率.我想得到一个类似该事件有84%的概率为真"的输出

Is there a way to convert this value to some odds or to directly get odds out of the ANN. I'd like to get an output like "The event has a 84% probability to be true"

推荐答案

一旦对NN进行了训练,例如.使用问题中提到的反向传播(从而使反向传播逻辑以最小化误差函数的方式加权"了权重),与所有单个输入(外部"输入或NN内部输入)关联的权重是固定的.然后可以将NN用于分类目的.

Once a NN has been trained, for eg. using backprogation as mentioned in the question (whereby the backprogation logic has "nudged" the weights in ways that minimize the error function) the weights associated with all individual inputs ("outside" inputs or intra-NN inputs) are fixed. The NN can then be used for classifying purposes.

因此,学习阶段的数学(和选项")可能会有些许复杂,当用作分类器时,它相对简单且直截了当.主要算法是计算每个神经元的激活值,作为该神经元的输入x权重之和.然后将此值馈送到激活函数,该函数的目的是对其进行规范化并将其转换为布尔值(在典型情况下,因为某些网络对其某些层没有完全或完全没有规则).激活函数可能比您指定的要复杂,特别是它不必是线性的,但是无论其形状(通常为S型),它都以相同的方式运行:找出激活在曲线上的位置,如果适用,请参见上文.或低于阈值.然后,基本算法将处理给定层上的所有神经元,然后再进行下一层.

Whereby the math (and the "options") during the learning phase can get a bit thick, it is relatively simple and straightfoward when operating as a classifier. The main algorithm is to compute an activation value for each neuron, as the sum of the input x weight for that neuron. This value is then fed to an activation function which purpose's is to normalize it and convert it to a boolean (in typical cases, as some networks do not have an all-or-nothing rule for some of their layers). The activation function can be more complex than you indicated, in particular it needn't be linear, but whatever its shape, typically sigmoid, it operate in the same fashion: figuring out where the activation fits on the curve, and if applicable, above or below a threshold. The basic algorithm then processes all neurons at a given layer before proceeding to the next.

考虑到这一点,使用感知器的能力以百分比值限定其猜测(或猜测-复数)的问题找到了一个简单的答案:您敢保证,其输出是实值的(如果需要进行标准化),则使用问题中所述的激活函数和阈值/比较方法将其转换为离散值(对于多个类别,则为布尔值或类别ID).

With this in mind, the question of using the perceptron's ability to qualify its guess (or indeed guesses - plural) with a percentage value, finds an easy answer: you bet it can, its output(s) is real-valued (if anything in need of normalizing) before we convert it to a discrete value (a boolean or a category ID in the case of several categories), using the activation functions and the threshold/comparison methods described in the question.

所以...如何以及在哪里获得我的百分比"?...全部取决于NN的实现,更重要的是,该实现决定了可用于将激活值带入到中的归一化函数的类型. 0-1范围的方式是所有百分比的总和加"为1.最简单的形式是,激活函数可用于将输入的值和权重归一化为输出层可以用作确保对"1个问题"进行累加"的因素(前提是这些权重本身确实已经标准化).

So... How and Where do I get "my percentages"?... All depends on the NN implementation, and more importantly, the implementation dictates the type of normalization functions that can be used to bring activation values in the 0-1 range and in a fashion that the sum of all percentages "add up" to 1. In its simplest form, the activation function can be used to normalize the value and the weights of the input to the output layer can be used as factors to ensure the "add up" to 1 question (provided that these weights are indeed so normalized themselves).

等等!

认证 :(遵循Mathieu的说明)
人们不需要改变神经网络本身的工作方式.唯一需要做的就是以某种方式钩住" 输出神经元的逻辑,以访问他们计算出的[实值]激活值,或者可能更好地访问神经元的实值输出.激活函数,先进行布尔转换(通常基于阈值或某种随机函数).

Claritication: (following Mathieu's note)
One doesn't need to change anything in the way the Neural Network itself works; the only thing needed is to somehow "hook into" the logic of output neurons to access the [real-valued] activation value they computed, or, possibly better, to access the real-valued output of the activation function, prior its boolean conversion (which is typically based on a threshold value or on some stochastic function).

换句话说,NN像以前一样工作,其训练或识别逻辑都没有改变,NN的输入保持不变,各层之间的连接等也是如此.我们只能得到实值的副本激活输出层中的神经元,我们用它来计算百分比.百分比计算的实际公式取决于激活值及其相关功能(其规模,相对于其他神经元输出的范围等)的性质.
以下是一些简单的案例(摘自问题的建议输出规则) 1)如果有单个输出神经元:激活函数提供的值相对于该函数范围的比值应该是正确的. 2)如果有两个(或多个输出神经元),例如分类器:如果所有输出神经元具有相同的激活函数,则给定神经元的百分比为其激活函数值的百分比除以所有激活函数之和价值观.如果激活功能发生变化,则因情况而异,因为不同的激活功能可能表示有意向某些神经元赋予更多权重的愿望,并且百分比应对此予以尊重.

In other words, the NN works as previously, neither its training nor recognition logic are altered, the inputs to the NN stay the same, as do the connections between various layers etc. We only get a copy of the real-valued activation of the neurons in the output layer, and we use this to compute a percentage. The actual formula for the percentage calculation depends on the nature of the activation value and its associated function (its scale, its range relative to other neurons' output etc.).
Here are a few simple cases (taken from the question's suggested output rules) 1) If there is a single output neuron: the ratio of the value provided by the activation function relative to the range of that function should do. 2) If there are two (or more output neurons), as with classifiers for example: If all output neurons have the same activation function, the percentage for a given neuron is that of its activation function value divided by the sum of all activation function values. If the activation functions vary, it becomes a case by case situation because the distinct activation functions may be indicative of a purposeful desire to give more weight to some of the neurons, and the percentage should respect this.

这篇关于如何将人工神经网络的输出转换为概率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆