如何仅在选定的几个标签上而不是多标签分类中的所有标签上进行反向传播?

发布于 2025-02-03 06:32:36 字数 350 浏览 4 评论 0原文

我在多个数据集上使用了验证的神经网络(RESNET)。

该神经网络的输出将具有所有数据集中存在的所有标签,也就是所有标签的结合。

例如:

如果数据集A具有标签X,Y,Z,W

数据集B具有标签-M,L,N,O,X,Y

dataset C C具有Labels-w,z,m,o

然后神经网络将在其最终层中具有所有标签,即is-> m,l,n,n,o,o,w,x,x,x,y,z 。

如何实现? 我在Pytorch工作。

I am using a pretrained neural network (resnet) on multiple datasets.

This neural network would have in it's output all the labels that are present in all the datasets,that is, like an union of all labels.

For example:

If dataset A has labels x,y,z,w

Dataset B has labels -m,l,n,o,x,y

Dataset C has labels-w,z,m,o

Then the neural network would have all labels in it's final layer-that is->m,l,n,o,w,x,y,z.

Now depending on which dataset I have, I want the model to train only on the dataset's own labels and not do backpropagation on other labels.

How can this be achieved?
I am working in Pytorch.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

唐婉 2025-02-10 06:32:36

也许使用三个损失函数,每个函数的参数具有不同的值 pos_weight ,以使其具有与数据集中未包含的类相对应的零。

Maybe use three loss functions each of which has different values for the argument pos_weight such that it has zeros corresponding to the classes not included in a dataset.

め可乐爱微笑 2025-02-10 06:32:36

您为什么要关心网络是否在其他标签上进行反向传播?这就是应该的工作方式。

如果这个想法是将输出功能的数量从验证的网络中减少,只需删除网络的最后一层,并与所需的输出功能添加。然后像你一样训练。

Why do you care if the network does backpropagation on other labels? That is how it is supposed to work.

If the idea is to reduce the number of output features from what they have in the pretrained network, just remove the last layer of the network and add in your own with the desired output features. Then train as you would.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文