You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/02/01 23:27:22 UTC
[GitHub] marcoabreu commented on a change in pull request #9675: Add contrib.compute_accidental_hits operator for candidate sampling
marcoabreu commented on a change in pull request #9675: Add contrib.compute_accidental_hits operator for candidate sampling
URL: https://github.com/apache/incubator-mxnet/pull/9675#discussion_r165519912
##########
File path: tests/python/unittest/test_sparse_ndarray.py
##########
@@ -843,6 +843,42 @@ def check_sparse_nd_norm(stype, shape, density):
for density in densities:
check_sparse_nd_norm(stype, shape, density)
+def test_sparse_nd_accidental_hit():
+ def compute_hits(label, sample):
+ num_label = len(label)
+ num_sample = len(sample)
+ label_indices = {}
+ # record all true classes indices
+ for i in range(num_label):
+ if label[i] not in label_indices:
+ label_indices[label[i]] = []
+ label_indices[label[i]].append(i)
+ accidental_hits = []
+ for i in range(num_sample):
+ s = sample[i]
+ if s in label_indices:
+ hits = label_indices[s]
+ accidental_hits += [(h, i) for h in hits]
+ return accidental_hits
+
+ n = 20
+ num_label = np.random.randint(1, 10)
Review comment:
Please initialize a fixed seed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services