多个神经网络,每个都有一个输出,或者一个有多个输出? [英] Multiple neural networks with one output each or one with multiple outputs?

查看:203
本文介绍了多个神经网络,每个都有一个输出,或者一个有多个输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将输入分类为三种可能性之一.最好使用3个网络,每个网络一个输出或1个网络,三个输出网络? (即3个输出01的网络或1个输出一个长度为3 [1,0,0]

I want to classify the input as one of 3 possibilities. Is it better to use 3 networks with one output each or 1 network with 3 outputs? (i.e. 3 networks that output 0 or 1 or 1 network that outputs a one hot vector of length 3 [1,0,0]

答案是否会根据传入数据的分类复杂程度而改变?

Does the answer change depending on how complex the incoming data is to classify?

以多少输出量划分网络(如果有的话)有意义吗?例如,如果我想分为20个组,这有什么区别吗?

At what amount of outputs does it make sense to partition the networks (if ever)? For example, if I want to classify into 20 groups, does it make a difference?

推荐答案

我想说使用具有多个输出的单个网络会更有意义.

I would say it would make more sense to use a single network with multiple outputs.

主要原因是隐藏层(我假设您将至少有一个隐藏层)可以解释为将数据从原始空间(特征空间)转换为更适合于任务(根据您的情况分类).例如,当训练网络从原始像素中识别人脸时,它可能会使用隐藏层首先检测简单的形状(例如,基于像素的小线条),然后使用另一个隐藏层来检测简单的形状(例如,基于像素的眼睛/鼻子)从第一层开始的线条,等等.(它可能不完全像这样干净",但这是一个易于理解的示例).

The main reason is that hidden layers (I'm assuming you'll have at least one hidden layer) can be interpreted as transforming the data from the original space (feature space) into a different space that is more suitable for the task (classification in your case). For example, when training a network to recognize faces from raw pixels, it might use a hidden layer to first detect simple shapes such as small lines based on pixels, then use another hidden layer to detect simple shapes such as eyes/noses based on the lines from the first layer, etc. (it may not be entirely as ''clean'' as this, but this is an easy-to-understand example).

网络可以学习的这种转换通常对于分类任务很有用,而与特定示例所具有的类无关.例如,不管实际图像是否包含面部,都能检测图像中的眼睛非常有用.如果确实检测到两只眼睛,则可以将其分类为面部,否则将其分类为不是面部.在这两种情况下,您都在寻找眼睛.

Such a transformation that a network can learn is typically useful for the classification task, regardless of what class the specific example has. For example, it is useful to be able to detect eyes in images regardless of whether or not the actual image contains a face; if you do indeed detect two eyes, you can classify it as a face, and otherwise you classify it as not being a face. In both cases, you were looking for eyes.

因此,通过拆分为多个网络,您可能最终仍会在所有网络中学习非常相似的模式.然后,您可能还省了自己的计算工作量,而只是学习了一次.

So, by splitting up into multiple networks, you may end up learning quite similar patterns in all networks anyway. Then you might as well have saved yourself the computational effort and just learned it once.

拆分为多个网络的另一个缺点是,您可能会导致数据集变得不平衡(如果已经不平衡,则可能更加不平衡).假设您有3个类别,每个类别的数据集恰好有1/3.如果将三个网络用于三个二进制分类任务,则突然会有1/3" 1"类和2/3" 0"类.这样一来,网络可能会偏向于在各处预测0,因为这是三个独立问题中的大多数.

Another disadvantage of splitting up into multiple networks would be that you would probably cause your dataset to become imbalanced (or more imbalanced if it already is imbalanced). Suppose you have three classes, with exactly 1/3 of the dataset belonging to each class. If you use three networks for three binary classification tasks, you suddenly always have 1/3 ''1'' classes and 2/3 ''0'' classes. A network may then become biased towards predicting 0s everywhere, since those are the majority classes in each of the three separate problems.

请注意,这都是基于我的直觉;如果有时间,最好的解决方案就是简单地尝试两种方法并进行测试!不过,我认为我在实践中从未见过有人使用多个网络来执行单个分类任务,因此,如果您只有时间使用一种方法,我建议您使用单个网络.

Note that this is all based on my intuition; the best solution if you have time would be to simply try both approaches and test! I don't think I have ever seen someone using multiple networks for a single classification task in practice though, so if you only have time for one approach I'd recommend going for a single network.

我认为使用多个网络真正有意义的唯一情况是,如果您实际上要预测多个不相关的值(或者至少要预测不相关的值).例如,如果给定图像,您想要1)预测图像上是否有狗,并且2)它是照片还是油画.那么最好使用两个网络,每个网络具有两个输出,而不是使用一个网络,具有四个输出.

I think the only case where it would really make sense to use multiple networks would be if you actually want to predict multiple unrelated values (or at least values that are not strongly related). For example, if, given images, you want to 1) predict whether or not there is a dog on the image, and 2) whether it is a photograph or a painting. Then it may be better to use two networks with two outputs each, instead of a single network with four outputs.

这篇关于多个神经网络,每个都有一个输出,或者一个有多个输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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