balancap / SSD-Tensorflow

Single Shot MultiBox Detector in TensorFlow
4.11k stars 1.89k forks source link

negtive sample choose problem #343

Open xuchengggg opened 5 years ago

xuchengggg commented 5 years ago

In def ssd_losses_old, nvalues = tf.where(nmask,predictions[:, :, :, :, 0],1. - fnmask), so nvalues = 1 if this anchor is positive and navalues = predictions[:,:,:,:,0], and is this predictions indicate the possibilities of background, and then val, idxes = tf.nn.top_k(-nvalues_flat, k=n_neg), is this meanings the negative samples are chosen which have low possibilities of background first?

understand94 commented 5 years ago

首先nvalues的意思就搞错了。nvalues在positive的时候为0,反之,对应为背景类的概率。top_k本身是取前K大的数,现在nvalues取反了,也就是说,idxes里面是最小的K个数,idxes[-1]指的是这K个小的数中最大的,在后面的代码直接用这个最大的数来筛选。