Git Product home page Git Product logo

triplet's People

Contributors

hizhangp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

triplet's Issues

Why i got this error ? Thanks

Traceback (most recent call last):
File "casiaWebface/triplet-master/train.py", line 94, in
sw = SolverWrapper(solver, output_dir, pretrained_model, gpu_id, data)
File "casiaWebface/triplet-master/train.py", line 32, in init
self.solver.net.layers[0].set_data(data)
File "/home/zlu/caffe/casiaWebface/triplet-master/triplet/data_layer.py", line 77, in set_data
self._shuffle_data()
File "/home/zlu/caffe/casiaWebface/triplet-master/triplet/data_layer.py", line 22, in _shuffle_data
np.random.choice(self._data._sample_person[person]))
File "mtrand.pyx", line 1110, in mtrand.RandomState.choice (numpy/random/mtrand/mtrand.c:17158)
ValueError: a must be non-empty

error when one batch sample with same label

for i in range(bottom[0].num):
label_index_map[bottom_label[i]].append(i)

    for i in range(bottom[0].num):
        anchor_label = bottom_label[i]
        anchor = bottom_data[i]

        for j in range(len(label_index_map[anchor_label])):
            positive_index = label_index_map[anchor_label][j]
            if len(label_index_map[anchor_label]) > 1 and positive_index == i:
                continue
            positive = bottom_data[positive_index]

            negative_label = anchor_label
            negative_index = np.random.choice(
                label_index_map[negative_label])
            negative = bottom_data[negative_index]
            # need semi-hard mining?
            semihard = True
            # max iteration
            max_iter = bottom[0].num * 2
            while len(label_index_map) > 1 and (negative_label == anchor_label or semihard):

when the label_index_map only have one key, which means that the samples within this batch own the same label, your code will generate a triplet within the same class?

Model performance in concern of SEMI_HARD value

Does setting "SEMI_HARD = True" have a obvious improvement on the model? (converging speed, accuracy, etc.) I'm setting it to FALSE, and it seems that the loss couldn't decrease after thousands of iteration.

BTW, would you be kind enough to provide any statistical result for your model using your datasets? Or how you evaluate your model?

ValueError: could not broadcast input array from shape (270,128) into shape (55,128)?

Hi, hizhangp, I have some problems during I running it, hoping you can give some advice, Thank you!

1.In tripletsample_layer.py,in the loop for j in range(len(label_index_map[anchor_label])):

top_anchor.append(anchor)
top_positive.append(positive)
top_negative.append(negative)
self.index_map.append([i, positive_index, negative_index])

There is following error

Solving...
I0829 15:46:58.676357 13370 solver.cpp:341] Iteration 0, Testing net (#0)
Semi-hard failed
Semi-hard failed
Traceback (most recent call last):
File "python/train.py", line 98, in
sw.train_model(max_iters)
File "python/train.py", line 60, in train_model
self.solver.step(1)
File "/home/zeng/caffe-master_p1/python/triplet/tripletsample_layer.py", line 102, in backward
bottom[0].diff[...] = bottom_diff
ValueError: could not broadcast input array from shape (270,128) into shape (55,128)

So I put it into for i in xrange(bottom[0].num): Is it correct?

2.test_iter can only to be 0,why?

Need your answer,thank you!

ValueError: a must be non-empty

Epoch 1
Shuffling the data ...
Traceback (most recent call last):
File "train.py", line 94, in
sw = SolverWrapper(solver, output_dir, pretrained_model, gpu_id, data)
File "train.py", line 32, in init
self.solver.net.layers[0].set_data(data)
File "/home/dl1/lvlu/triplet-master/triplet/data_layer.py", line 77, in set_data
self._shuffle_data()
File "/home/dl1/lvlu/triplet-master/triplet/data_layer.py", line 22, in _shuffle_data
np.random.choice(self._data._sample_person[person]))
File "mtrand.pyx", line 1080, in mtrand.RandomState.choice (numpy/random/mtrand/mtrand.c:10392)
ValueError: a must be non-empty

error when one batch sample with same label

for i in range(bottom[0].num):
label_index_map[bottom_label[i]].append(i)

    for i in range(bottom[0].num):
        anchor_label = bottom_label[i]
        anchor = bottom_data[i]

        for j in range(len(label_index_map[anchor_label])):
            positive_index = label_index_map[anchor_label][j]
            if len(label_index_map[anchor_label]) > 1 and positive_index == i:
                continue
            positive = bottom_data[positive_index]

            negative_label = anchor_label
            negative_index = np.random.choice(
                label_index_map[negative_label])
            negative = bottom_data[negative_index]
            # need semi-hard mining?
            semihard = True
            # max iteration
            max_iter = bottom[0].num * 2
            while len(label_index_map) > 1 and (negative_label == anchor_label or semihard):

when the label_index_map only have one key, which means that the samples within this batch own the same label, your code will generate a triplet within the same class?

AttributeError: 'DataLayer' object has no attribute '_data'

I am using the triplet loss with my inception batch-norm network. And it breaks down on the 1st iteration.

Epoch 1
Shuffling the data ...
Solving...
I1216 21:59:13.990463  6601 solver.cpp:337] Iteration 0, Testing net (#0)
Traceback (most recent call last):
  File "triplet_train.py", line 97, in <module>
    sw.train_model(max_iters)
  File "triplet_train.py", line 59, in train_model
    self.solver.step(1)
  File "/home/wenfahu/inception_bn_face/triplet/data_layer.py", line 107, in forward
    blobs = self._get_next_minibatch()
  File "/home/wenfahu/inception_bn_face/triplet/data_layer.py", line 37, in _get_next_minibatch
    if self._index + self.batch_size <= len(self._data._sample):
AttributeError: 'DataLayer' object has no attribute '_data'

训练时,跑tripletsample层反向出错

tripletsample_layer.py", line 102, in backward
bottom[0].diff[...] = bottom_diff
ValueError: could not broadcast input array from shape (200,128) into shape (50,128)
我batchsize设的50

Error in data_layer function "_get_next_minibatch"

Hello,

I was trying to run this code with this dataset: http://vis-www.cs.umass.edu/lfw/
I needed to fix some problems in code, but has one I could not fix, when I run "train.py" I got this error below:

  File "/home/user/projects/triplet/data_layer.py", line 36, in _get_next_minibatch
    print('lenAttributeError: 'DataLayer' object has no attribute '_data'

(self._data._sample): '+str(len(self._data._sample)))

I can't see where this error occur, because my code execute that function "_shuffle_data" the same object and printed "self._data" without problems, when I was trying to execute "sw.train_model(max_iters)" (in "train.py") this error to occur.

Is there any experience on determining the value of margin ?

Hello,
Do you have any idea on how to determine the value of the margin in triplet loss formula? I saw you assigned 0.2 to the margin in your code. But I also noticed other people assigned 1 to it somewhere else. Can you give me some tips on choosing the value of margin ? Thank you a lot !

The loss remains high after thousands of iterations

您好!我使用您的代码在Facescrub上训练。我在pretrain(对530个人进行分类)中,iteration经过3000多之后loss仍然一直保持6.25左右徘徊。accuracy也是不到0.01%,所以想问问。由于我在车辆识别上也在做类似FaceNet的任务,我仿照您的代码也写了车辆型号的分类,loss也是一样的趋势,保持5以上。我想请问这个趋势正常吗?周围同事说这个趋势不常见,所以想问问您!谢谢!

AttributeError: 'DataLayer' object has no attribute '_data'

您好!train.py中训练之前确实执行了self.solver.net.layers[0].set_data(data),但是还是会报这个错误。打印的中间信息似乎说明这里实例化了两个网络,一个phase是0,一个phase是1,请问我错在哪了呢?网络结构用的是您贴出来的vgg16-face...谢谢!
image

提取哪一层的特征

您好,我想请教一下测试的时候是提取"fc7"还是"fc9_1"作为模型特征?谢谢!

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.