mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
function to merge feature scores. ie. not add them together.
This commit is contained in:
parent
117eb76b0a
commit
47902053b5
@ -803,6 +803,28 @@ FValue FVector::inner_product(const FVector& rhs) const
|
||||
return product;
|
||||
}
|
||||
|
||||
void FVector::merge(const FVector &other)
|
||||
{
|
||||
// dense
|
||||
for (size_t i = 0; i < m_coreFeatures.size(); ++i) {
|
||||
FValue thisVal = m_coreFeatures[i];
|
||||
FValue otherVal = other.m_coreFeatures[i];
|
||||
|
||||
if (otherVal) {
|
||||
CHECK(thisVal == 0 || thisVal == otherVal);
|
||||
thisVal = otherVal;
|
||||
}
|
||||
}
|
||||
|
||||
// sparse
|
||||
FNVmap::const_iterator iter;
|
||||
for (iter = other.m_features.begin(); iter != other.m_features.end(); ++iter) {
|
||||
const FName &otherKey = iter->first;
|
||||
const FValue otherVal = iter->second;
|
||||
m_features[otherKey] = otherVal;
|
||||
}
|
||||
}
|
||||
|
||||
const FVector operator+(const FVector& lhs, const FVector& rhs)
|
||||
{
|
||||
return FVector(lhs) += rhs;
|
||||
|
@ -257,6 +257,8 @@ public:
|
||||
// divide each element by the number given in the rhs vector
|
||||
FVector& divideEquals(const FVector& rhs);
|
||||
|
||||
void merge(const FVector &other);
|
||||
|
||||
#ifdef MPI_ENABLE
|
||||
friend class boost::serialization::access;
|
||||
#endif
|
||||
|
@ -376,6 +376,9 @@ public:
|
||||
void UpdateLearningRates(float decay_core, float decay_sparse, ScoreComponentCollection &confidenceCounts, float core_r0, float sparse_r0) {
|
||||
m_scores.updateLearningRates(decay_core, decay_sparse, confidenceCounts.m_scores, core_r0, sparse_r0);
|
||||
}
|
||||
void Merge(const ScoreComponentCollection &other) {
|
||||
m_scores.merge(other.m_scores);
|
||||
}
|
||||
|
||||
#ifdef MPI_ENABLE
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user