Merged
Conversation
…h original implementation
…h original implementation
| std::make_pair(query[i], std::vector<PredictionResult>())); | ||
| } | ||
| predictions[query[i]].push_back(PredictionResult( | ||
| score[i * width + column], label[i], has_weight ? weight[i] : 1.0)); |
Contributor
There was a problem hiding this comment.
这里是不是也可以用emplace?
predictions[query[i]].emplace_back(score[i * width + column], label[i], has_weight ? weight[i] : 1.0);
| auto query = query_t->data<int32_t>(); | ||
| const T* weight = nullptr; | ||
| auto has_weight = weight_t != nullptr; | ||
| if (has_weight) { |
Contributor
There was a problem hiding this comment.
Why not if (weight_t != nullptr) and remove line 52 ?
|
|
||
| auto score = score_t->data<T>(); | ||
| auto label = label_t->data<T>(); | ||
| auto query = query_t->data<int32_t>(); |
Contributor
There was a problem hiding this comment.
我们要不要考虑query id有可能不是数字的情况?
即使我们只支持数字的话,这里用size_t是不是更合适?
Contributor
Author
There was a problem hiding this comment.
- 我似乎没看到我们有支持string类型tensor的design doc,所以我假定这里是原来的实现一样,只支持整数的;而且由于这里事实上是ID,所以用数字也是比较符合直觉的。之后如果有其它需要我们可以再扩展。
- 我参考了下其它要用到int类型input的op(lookup_table_op, top_k_op), 这里用
int32_t确实和它们用int64_t不一致,所以我把这里改为int64_t了。size_t是unsigned,和这里语义有区别。
| # group by query id | ||
| predictions = {} | ||
| batch_size = label.shape[0] | ||
| print "batch_size=", batch_size |
| self.check_output() | ||
|
|
||
|
|
||
| class TestPositiveNegativePairOpAccumulateWeight(OpTest): |
Contributor
There was a problem hiding this comment.
TestPositiveNegativePairOpAccumulate 和TestPositiveNegativePairOpAccumulateWeight 有比较多的重复code, 可以考虑合并下。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This evaluator counts positive pairs, negative pairs in the ranking result.
Tested on the 1-dimension score case.
resolve #5086