'A'、'B' 或 'any' 类型的三元分类?
Ternary Classification of the type 'A', 'B' or 'any'?
对于任何通用机器学习模型(尽管我目前正在使用神经网络),对于
的任务
classifying the elements of a set into three groups ('A' or 'B' or 'any'),
(这里,标记为'A'意味着只有有效标签是'A'(类似'B'), 和 'any' 表示 both 标签 'A' 和 'B'同样有效),应该使用什么样的损失函数?
这可以使用与更普遍的“三元分类”问题相关的技术来解决,但我认为这种概括会丢失一些信息。
举例来说,假设我们要根据时态形式对动词(英语)进行分类(让我们只考虑现在时和过去时)
那么模型应该分类
{"work", "eat", "sing", ...} as "present tense"
{"worked", "ate", "sang", ...} as "past tense"
并且,
{"read", "put", "cut", ...} as "any"
(注意 'read' 的现在时和过去时发音不同,但我们正在考虑基于文本的分类)
这与我正在处理的任务不同,但可能应该作为这个特定问题的有效示例。
PS: 我是一名学生,对这个领域只有基本的了解,所以如果需要的话,请就此问题进行任何说明。
我认为你是multi-labelclass化而不是multi-classclass化。
如前所述here:
In machine learning, multi-label classification and the strongly
related problem of multi-output classification are variants of the
classification problem where multiple labels may be assigned to each
instance
这意味着实例可以关联超过 1 个 class。
通常,当您使用二进制 class化(例如 0、1 classes)时,您可以将一个神经元作为网络的最后一层,它将输出介于 0 之间的连续值和 1,使用 sigmoid 作为激活函数,作为损失 binary cross-entropy
鉴于您的情况,您可以决定使用:
- 两个神经元作为神经网络的输出
- 对于每一个你都可以使用
sigmoid
激活函数
- 作为损失
binary-cross entropy
通过这种方式,每个实例都可以通过模型以特定概率与两个 class 关联。
这意味着对于每个实例,您应该关联两个 class,或者 “标签”。
例如,对于你的动词,你应该有“过去”、“现在”classes:
present past
work: 1 0
worked: 0 1
read 1 1
并且您的模型将尝试输出两个概率,其架构如前所述:
present past sum
work: 0.9 0.3 1.2
worked: 0.21 0.8 1.01
read 0.86 0.7 1.5
基本上,你有两个独立的概率(如果检查,一行的总和不是 1),因此你可以将两个 classes.
关联到一个实例
相反,如果你想要一个互斥的class化,超过2个class,你应该使用categorical crossentropy
作为损失,softmax activation function
在你的最后一层中,它基本上将处理输出以生成总和为 1 的概率向量。Example
present past both sum
work: 0.7 0.2 0.1 1
worked: 0.21 0.7 0.19 1
read 0.33 0.33 0.33 1
检查 here 以查看详细示例
对于任何通用机器学习模型(尽管我目前正在使用神经网络),对于
的任务classifying the elements of a set into three groups ('A' or 'B' or 'any'),
(这里,标记为'A'意味着只有有效标签是'A'(类似'B'), 和 'any' 表示 both 标签 'A' 和 'B'同样有效),应该使用什么样的损失函数?
这可以使用与更普遍的“三元分类”问题相关的技术来解决,但我认为这种概括会丢失一些信息。
举例来说,假设我们要根据时态形式对动词(英语)进行分类(让我们只考虑现在时和过去时)
那么模型应该分类
{"work", "eat", "sing", ...} as "present tense"
{"worked", "ate", "sang", ...} as "past tense"
并且,
{"read", "put", "cut", ...} as "any"
(注意 'read' 的现在时和过去时发音不同,但我们正在考虑基于文本的分类)
这与我正在处理的任务不同,但可能应该作为这个特定问题的有效示例。
PS: 我是一名学生,对这个领域只有基本的了解,所以如果需要的话,请就此问题进行任何说明。
我认为你是multi-labelclass化而不是multi-classclass化。
如前所述here:
In machine learning, multi-label classification and the strongly related problem of multi-output classification are variants of the classification problem where multiple labels may be assigned to each instance
这意味着实例可以关联超过 1 个 class。
通常,当您使用二进制 class化(例如 0、1 classes)时,您可以将一个神经元作为网络的最后一层,它将输出介于 0 之间的连续值和 1,使用 sigmoid 作为激活函数,作为损失 binary cross-entropy
鉴于您的情况,您可以决定使用:
- 两个神经元作为神经网络的输出
- 对于每一个你都可以使用
sigmoid
激活函数 - 作为损失
binary-cross entropy
通过这种方式,每个实例都可以通过模型以特定概率与两个 class 关联。
这意味着对于每个实例,您应该关联两个 class,或者 “标签”。 例如,对于你的动词,你应该有“过去”、“现在”classes:
present past
work: 1 0
worked: 0 1
read 1 1
并且您的模型将尝试输出两个概率,其架构如前所述:
present past sum
work: 0.9 0.3 1.2
worked: 0.21 0.8 1.01
read 0.86 0.7 1.5
基本上,你有两个独立的概率(如果检查,一行的总和不是 1),因此你可以将两个 classes.
关联到一个实例相反,如果你想要一个互斥的class化,超过2个class,你应该使用categorical crossentropy
作为损失,softmax activation function
在你的最后一层中,它基本上将处理输出以生成总和为 1 的概率向量。Example
present past both sum
work: 0.7 0.2 0.1 1
worked: 0.21 0.7 0.19 1
read 0.33 0.33 0.33 1
检查 here 以查看详细示例