This is an automated email from the ASF dual-hosted git repository. haibin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push: new 632f514 Sampling negative samples other classes only (#10980) 632f514 is described below commit 632f5140a69b51ff87129e6742e5be46684dc58c Author: Jon <jonbakerf...@gmail.com> AuthorDate: Thu May 17 13:39:37 2018 +0930 Sampling negative samples other classes only (#10980) The original code will have a chance to sample negative samples from the same class of the anchors --- example/gluon/embedding_learning/model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/example/gluon/embedding_learning/model.py b/example/gluon/embedding_learning/model.py index 91f7735..f82240e 100644 --- a/example/gluon/embedding_learning/model.py +++ b/example/gluon/embedding_learning/model.py @@ -108,6 +108,7 @@ class DistanceWeightedSampling(HybridBlock): mask = np.ones(weights.shape) for i in range(0, n, k): mask[i:i+k, i:i+k] = 0 + mask_uniform_probs = mask * (1.0/(n-k)) weights = weights * F.array(mask) * (distance < self.nonzero_loss_cutoff) weights_sum = F.sum(weights, axis=1, keepdims=True) @@ -125,7 +126,7 @@ class DistanceWeightedSampling(HybridBlock): n_indices += np.random.choice(n, k-1, p=np_weights[i]).tolist() else: # all samples are above the cutoff so we sample uniformly - n_indices += np.random.choice(n, k-1).tolist() + n_indices += np.random.choice(n, k-1, p=mask_uniform_probs[i]).tolist() for j in range(block_idx * k, (block_idx + 1) * k): if j != i: a_indices.append(i) -- To stop receiving notification emails like this one, please contact hai...@apache.org.