blob: 6db0c045da1480f3277d3bac7cc3c570adaffcb4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#ifndef _DTRAIN_PAIRSAMPLING_H_
#define _DTRAIN_PAIRSAMPLING_H_
namespace dtrain
{
inline void
sample_all_pairs(vector<ScoredHyp>* s, vector<pair<ScoredHyp,ScoredHyp> > &training)
{
for (unsigned i = 0; i < s->size()-1; i++) {
for (unsigned j = i+1; j < s->size(); j++) {
pair<ScoredHyp,ScoredHyp> p;
p.first = (*s)[i];
p.second = (*s)[j];
training.push_back(p);
}
}
}
inline void
sample_rand_pairs(vector<ScoredHyp>* s, vector<pair<ScoredHyp,ScoredHyp> > &training,
MT19937* prng)
{
for (unsigned i = 0; i < s->size()-1; i++) {
for (unsigned j = i+1; j < s->size(); j++) {
if (prng->next() < .5) {
pair<ScoredHyp,ScoredHyp> p;
p.first = (*s)[i];
p.second = (*s)[j];
training.push_back(p);
}
}
}
}
} // namespace
#endif
|