Git Product home page Git Product logo

Comments (25)

jiangxuehan avatar jiangxuehan commented on July 26, 2024 4

@pinguo-luhaofang 我觉得 @chendd14 的说法是对的
如果按照
if aps[i][1] >= ans[i][1]:
self.no_residual_list.append(i) 这个逻辑
hard samples(aps[i][1] >= ans[i][1]:)都不反传梯度了

from tripletloss.

luhaofang avatar luhaofang commented on July 26, 2024 2

对的,每次取10对,在反传梯度的时候进行样本筛选的调整,这里进行排序只是为尽可能让更多的triplet满足筛选条件。

from tripletloss.

luhaofang avatar luhaofang commented on July 26, 2024 2

@BrettLL 我是通过不回传梯度,来达到样本对semi-hard的筛选的目的。那些符合筛选条件的样本对会进行参数更新。

from tripletloss.

LiuJinxue avatar LiuJinxue commented on July 26, 2024 2

@jiangxuehan @chendd14 我觉的
if aps[i][1] >= ans[i][1]:
self.no_residual_list.append(i)
这个逻辑是对的,hard negative 是不参与误差反传的,因为有可能导致bad local minimal
这个在FaceNet文章的公式(4)当中有做了说明。 只选择 ans > aps的样本

from tripletloss.

dianxin556 avatar dianxin556 commented on July 26, 2024

datalayer层中每个人选了十对triplet,但是select里面怎么保证每对都满足条件呢?还是把不满足条件的triplet舍弃掉,还有如果每个人的样本数量不固定,比较少的话。这个策略是不是不适用

from tripletloss.

luhaofang avatar luhaofang commented on July 26, 2024

@dianxin556 你好,谢谢你的提问,如果每次选择的样本都存在问题,那么说明cnn的分类模型训练是存在问题的。

from tripletloss.

yzk0281 avatar yzk0281 commented on July 26, 2024

好像vgg对数据均衡要求比较高 每个人的样本数量相差太大的话 很难收敛,,
亲身体会

from tripletloss.

dianxin556 avatar dianxin556 commented on July 26, 2024

谢谢@pinguo-luhaofnag,@yzk0281.那每次输入的batchsize必须是固定的吗?还是只要是3的倍数就可以。

from tripletloss.

yzk0281 avatar yzk0281 commented on July 26, 2024

我就取的30

from tripletloss.

dianxin556 avatar dianxin556 commented on July 26, 2024

如果不指定大小可以吗,比如说一个人下面有n个样本,就用n*3这么大可以吗

from tripletloss.

yzk0281 avatar yzk0281 commented on July 26, 2024

这个,,,我就不知道了 luhaofang大神来回答下。。

from tripletloss.

BrettLL avatar BrettLL commented on July 26, 2024

@pinguo-luhaofang 这样选择的10对样本有可能有的并不满足aps[i][1] >= ans[i][1]的条件,还是只选择10对样本中满足这个条件的样本对?那是不是应该是:
if aps[i][1] >= ans[i][1]:
self.no_residual_list.append(i)
else:
self.tripletlist.append([i,aps[i][0],ans[i][0]])

from tripletloss.

dianxin556 avatar dianxin556 commented on July 26, 2024

@pinguo-luhaofang ,我看你前一个版本选择的条件是写if an>ap,.....
最新的版本是ap>=an,新版的这个是不满足条件的样本吗?

from tripletloss.

luhaofang avatar luhaofang commented on July 26, 2024

2个版本的选择条件都是an > ap ,差异在于当前的代码使用的是记录minibatch里边不符合筛选条件的样本对code1
在回传梯度的时候,这部分的样本是没有返回梯度的 code2

from tripletloss.

dianxin556 avatar dianxin556 commented on July 26, 2024

@pinguo-luhaofang ,恩,谢谢。那你算loss的时候,是没有去除这些样本,并且把不产生loss的也加入了no_residual_list,对吧?您在数据集上训练的话,多久可以看到收敛?

from tripletloss.

luhaofang avatar luhaofang commented on July 26, 2024

这些样本对是产生loss的,因为他们经过loss function计算出的值是不为0的。
一个epoch(全样本图片各抽样一次),就开始收敛了。

from tripletloss.

chendd14 avatar chendd14 commented on July 26, 2024

@pinguo-luhaofang 你现在的代码是,
if aps[i][1] >= ans[i][1]:
self.no_residual_list.append(i)
else:
self.tripletlist.append([i,aps[i][0],ans[i][0]])
我怎么觉得应该是
if aps[i][1] <= ans[i][1]:
self.no_residual_list.append(i)
else:
self.tripletlist.append([i,aps[i][0],ans[i][0]])

from tripletloss.

lcj1105 avatar lcj1105 commented on July 26, 2024

@pinguo-luhaofang @chendd14 你们对于现在这个版本的代码有做实验了吗?
ap>an指的是那些有损失的,但是这个时候self.no_residual_list.append(i) 这样的逻辑确实反了吧?

from tripletloss.

qiufan avatar qiufan commented on July 26, 2024

@pinguo-luhaofang 个人感觉错了 我个人把这两行注释掉了 因为之后的一层里面已经有了判断 现在跑了跑 lfw分类效果确实提升了 但是还是没收敛=-= 感觉收敛了效果应该会不错

from tripletloss.

yzk0281 avatar yzk0281 commented on July 26, 2024

@qiufan
现在收敛了没?效果怎样

from tripletloss.

qiufan avatar qiufan commented on July 26, 2024

@yzk0281 没=-= 需要研究一下 又跑了3天基本没变化

from tripletloss.

tanyuan1992 avatar tanyuan1992 commented on July 26, 2024

@qiufan 请问你做embedding的时候 用的什么数据进行的 ?是用的vgg基本模型训练时候的数据还是要进行测试的数据,比如lfw?

from tripletloss.

qiufan avatar qiufan commented on July 26, 2024

@LiuJinxue 对的, 我后来又仔细的看了论文, 这个地方是对的。然而我还是没能收敛,因为数据库的问题源码里面的triplet 选择代码总会在随机的数的时候无限循环,自己改了之后又不能收敛。不知道是不是triplet 的选择需要多多注意?

from tripletloss.

LiuJinxue avatar LiuJinxue commented on July 26, 2024

@qiufan 无线循环是因为anchor找不到足够的positvie, 可以减少batch_size, 或者增加数据集每个类别的样本数量,每一类必须不少于batch_size/3 + 1的图片数。我的问题是收敛得太快了,所以就改小了lr。但最终的实验效果还是不如直接用vgg的fc7层

from tripletloss.

qiufan avatar qiufan commented on July 26, 2024

@LiuJinxue 嗯,谢谢。我知道是无限循环的原因。那是不是说,每一次训练,都需要anchor保持同一类?完全随机是不可以的?还是不能收敛好忧桑。。。

from tripletloss.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.