#include <FeatureVector.h>
Public Types | |
typedef boost::unordered_map < FName, FValue, FNameHash, FNameEquals > | FNVmap |
typedef FNVmap::iterator | iterator |
typedef FNVmap::const_iterator | const_iterator |
Public Member Functions | |
FVector (size_t coreFeatures=0) | |
FVector & | operator= (const FVector &rhs) |
void | resize (size_t newsize) |
iterator | begin () |
iterator | end () |
const_iterator | cbegin () const |
const_iterator | cend () const |
bool | hasNonDefaultValue (FName name) const |
void | clear () |
bool | load (const std::string &filename) |
void | save (const std::string &filename) const |
void | write (std::ostream &out, const std::string &sep=" ", const std::string &linesep="\n") const |
ProxyFVector | operator[] (const FName &name) |
FValue & | operator[] (size_t index) |
FValue | operator[] (const FName &name) const |
FValue | operator[] (size_t index) const |
size_t | size () const |
size_t | coreSize () const |
const std::valarray< FValue > & | getCoreFeatures () const |
bool | operator== (const FVector &rhs) const |
bool | operator!= (const FVector &rhs) const |
FValue | inner_product (const FVector &rhs) const |
FVector & | operator+= (const FVector &rhs) |
FVector & | operator-= (const FVector &rhs) |
FVector & | operator*= (const FVector &rhs) |
FVector & | operator/= (const FVector &rhs) |
FVector & | operator*= (const FValue &rhs) |
FVector & | operator/= (const FValue &rhs) |
FVector & | multiplyEqualsBackoff (const FVector &rhs, float backoff) |
FVector & | multiplyEquals (float core_r0, float sparse_r0) |
FVector & | max_equals (const FVector &rhs) |
FValue | l1norm () const |
FValue | l1norm_coreFeatures () const |
FValue | l2norm () const |
FValue | linfnorm () const |
size_t | l1regularize (float lambda) |
void | l2regularize (float lambda) |
size_t | sparseL1regularize (float lambda) |
void | sparseL2regularize (float lambda) |
FValue | sum () const |
std::ostream & | print (std::ostream &out) const |
void | printCoreFeatures () |
void | thresholdScale (float maxValue) |
void | capMax (FValue maxValue) |
void | capMin (FValue minValue) |
void | sparsePlusEquals (const FVector &rhs) |
void | corePlusEquals (const FVector &rhs) |
void | coreAssign (const FVector &rhs) |
void | incrementSparseHopeFeatures () |
void | incrementSparseFearFeatures () |
void | printSparseHopeFeatureCounts (std::ofstream &out) |
void | printSparseFearFeatureCounts (std::ofstream &out) |
void | printSparseHopeFeatureCounts () |
void | printSparseFearFeatureCounts () |
size_t | pruneSparseFeatures (size_t threshold) |
size_t | pruneZeroWeightFeatures () |
void | updateConfidenceCounts (const FVector &weightUpdate, bool signedCounts) |
void | updateLearningRates (float decay_core, float decay_sparse, const FVector &confidence_counts, float core_r0, float sparse_r0) |
void | setToBinaryOf (const FVector &rhs) |
FVector & | coreDivideEquals (float scalar) |
FVector & | divideEquals (const FVector &rhs) |
void | merge (const FVector &other) |
Friends | |
class | ProxyFVector |
void | swap (FVector &first, FVector &second) |
Definition at line 127 of file FeatureVector.h.
typedef FNVmap::const_iterator Moses::FVector::const_iterator |
Definition at line 147 of file FeatureVector.h.
typedef boost::unordered_map<FName,FValue,FNameHash, FNameEquals> Moses::FVector::FNVmap |
Definition at line 144 of file FeatureVector.h.
typedef FNVmap::iterator Moses::FVector::iterator |
Iterators
Definition at line 146 of file FeatureVector.h.
Moses::FVector::FVector | ( | size_t | coreFeatures = 0 |
) |
Empty feature vector
Definition at line 165 of file FeatureVector.cpp.
iterator Moses::FVector::begin | ( | ) | [inline] |
Definition at line 148 of file FeatureVector.h.
Referenced by l1regularize(), l2regularize(), multiplyEquals(), multiplyEqualsBackoff(), operator*=(), operator/=(), sparseL1regularize(), and sparseL2regularize().
void Moses::FVector::capMax | ( | FValue | maxValue | ) |
Definition at line 338 of file FeatureVector.cpp.
References cbegin(), and cend().
Referenced by Moses::ScoreComponentCollection::CapMax().
void Moses::FVector::capMin | ( | FValue | minValue | ) |
Definition at line 345 of file FeatureVector.cpp.
References cbegin(), and cend().
Referenced by Moses::ScoreComponentCollection::CapMin().
const_iterator Moses::FVector::cbegin | ( | ) | const [inline] |
Definition at line 154 of file FeatureVector.h.
Referenced by capMax(), capMin(), divideEquals(), Moses::ScoreComponentCollection::GetNumberWeights(), Moses::ScoreComponentCollection::GetVectorForProducer(), incrementSparseFearFeatures(), incrementSparseHopeFeatures(), inner_product(), l1norm(), linfnorm(), Moses::ScoreComponentCollection::MultiplyEquals(), operator+=(), operator-=(), operator==(), Moses::ScoreComponentCollection::OutputFeatureScores(), Moses::PackScores(), printSparseFearFeatureCounts(), printSparseHopeFeatureCounts(), pruneSparseFeatures(), pruneZeroWeightFeatures(), setToBinaryOf(), sparsePlusEquals(), sum(), thresholdScale(), updateConfidenceCounts(), and updateLearningRates().
const_iterator Moses::FVector::cend | ( | ) | const [inline] |
Definition at line 157 of file FeatureVector.h.
Referenced by capMax(), capMin(), divideEquals(), Moses::ScoreComponentCollection::GetNumberWeights(), Moses::ScoreComponentCollection::GetVectorForProducer(), incrementSparseFearFeatures(), incrementSparseHopeFeatures(), inner_product(), l1norm(), linfnorm(), Moses::ScoreComponentCollection::MultiplyEquals(), operator+=(), operator-=(), operator==(), Moses::ScoreComponentCollection::OutputFeatureScores(), Moses::PackScores(), printSparseFearFeatureCounts(), printSparseHopeFeatureCounts(), pruneSparseFeatures(), pruneZeroWeightFeatures(), setToBinaryOf(), sparsePlusEquals(), sum(), thresholdScale(), updateConfidenceCounts(), and updateLearningRates().
void Moses::FVector::clear | ( | ) |
Definition at line 176 of file FeatureVector.cpp.
Referenced by load(), and Moses::ScoreComponentCollection::ZeroAll().
void Moses::FVector::coreAssign | ( | const FVector & | rhs | ) |
Definition at line 397 of file FeatureVector.cpp.
Referenced by Moses::ScoreComponentCollection::CoreAssign().
FVector & Moses::FVector::coreDivideEquals | ( | float | scalar | ) |
Definition at line 529 of file FeatureVector.cpp.
Referenced by Moses::ScoreComponentCollection::CoreDivideEquals().
void Moses::FVector::corePlusEquals | ( | const FVector & | rhs | ) |
Definition at line 388 of file FeatureVector.cpp.
References resize().
Referenced by Moses::ScoreComponentCollection::CorePlusEquals().
size_t Moses::FVector::coreSize | ( | ) | const [inline] |
Definition at line 183 of file FeatureVector.h.
Referenced by Moses::ScoreComponentCollection::Resize().
Definition at line 537 of file FeatureVector.cpp.
References cbegin(), and cend().
Referenced by Moses::ScoreComponentCollection::DivideEquals().
iterator Moses::FVector::end | ( | ) | [inline] |
Definition at line 151 of file FeatureVector.h.
Referenced by l1regularize(), l2regularize(), multiplyEquals(), multiplyEqualsBackoff(), operator*=(), operator/=(), sparseL1regularize(), and sparseL2regularize().
const std::valarray<FValue>& Moses::FVector::getCoreFeatures | ( | ) | const [inline] |
Definition at line 187 of file FeatureVector.h.
Referenced by Moses::ScoreComponentCollection::getCoreFeatures().
bool Moses::FVector::hasNonDefaultValue | ( | FName | name | ) | const [inline] |
Definition at line 161 of file FeatureVector.h.
void Moses::FVector::incrementSparseFearFeatures | ( | ) |
Definition at line 409 of file FeatureVector.cpp.
References cbegin(), cend(), and Moses::FName::incrementFearId().
Referenced by Moses::ScoreComponentCollection::IncrementSparseFearFeatures().
void Moses::FVector::incrementSparseHopeFeatures | ( | ) |
Definition at line 403 of file FeatureVector.cpp.
References cbegin(), cend(), and Moses::FName::incrementHopeId().
Referenced by Moses::ScoreComponentCollection::IncrementSparseHopeFeatures().
Definition at line 805 of file FeatureVector.cpp.
References cbegin(), and cend().
Referenced by Moses::ScoreComponentCollection::GetWeightedScore(), Moses::inner_product(), Moses::ScoreComponentCollection::InnerProduct(), and l2norm().
FValue Moses::FVector::l1norm | ( | ) | const |
norms and sums
Definition at line 654 of file FeatureVector.cpp.
References cbegin(), and cend().
Referenced by BOOST_AUTO_TEST_CASE(), and Moses::ScoreComponentCollection::GetL1Norm().
FValue Moses::FVector::l1norm_coreFeatures | ( | ) | const |
Definition at line 666 of file FeatureVector.cpp.
Referenced by Moses::ScoreComponentCollection::L1Normalise().
size_t Moses::FVector::l1regularize | ( | float | lambda | ) |
Definition at line 696 of file FeatureVector.cpp.
References begin(), end(), Moses::FName::eraseId(), Moses::FName::getId(), and size().
Referenced by Moses::ScoreComponentCollection::L1Regularize().
FValue Moses::FVector::l2norm | ( | ) | const |
Definition at line 675 of file FeatureVector.cpp.
References inner_product().
Referenced by BOOST_AUTO_TEST_CASE(), and Moses::ScoreComponentCollection::GetL2Norm().
void Moses::FVector::l2regularize | ( | float | lambda | ) |
Definition at line 734 of file FeatureVector.cpp.
References begin(), and end().
Referenced by Moses::ScoreComponentCollection::L2Regularize().
FValue Moses::FVector::linfnorm | ( | ) | const |
Definition at line 680 of file FeatureVector.cpp.
References cbegin(), and cend().
Referenced by Moses::ScoreComponentCollection::GetLInfNorm().
bool Moses::FVector::load | ( | const std::string & | filename | ) |
Load from file - each line should be 'root[_name] value'
Definition at line 182 of file FeatureVector.cpp.
References clear().
Referenced by Moses::ScoreComponentCollection::Load().
void Moses::FVector::merge | ( | const FVector & | other | ) |
Definition at line 818 of file FeatureVector.cpp.
Referenced by Moses::ScoreComponentCollection::Merge().
FVector & Moses::FVector::multiplyEquals | ( | float | core_r0, | |
float | sparse_r0 | |||
) |
Definition at line 644 of file FeatureVector.cpp.
References begin(), and end().
Referenced by Moses::ScoreComponentCollection::MultiplyEquals().
Definition at line 624 of file FeatureVector.cpp.
References begin(), end(), and resize().
Referenced by Moses::ScoreComponentCollection::MultiplyEqualsBackoff().
bool Moses::FVector::operator!= | ( | const FVector & | rhs | ) | const |
Definition at line 253 of file FeatureVector.cpp.
Definition at line 605 of file FeatureVector.cpp.
References begin(), and end().
Definition at line 561 of file FeatureVector.cpp.
References begin(), end(), and resize().
Referenced by thresholdScale().
arithmetic
Definition at line 369 of file FeatureVector.cpp.
References cbegin(), cend(), and resize().
Definition at line 547 of file FeatureVector.cpp.
References cbegin(), cend(), and resize().
Definition at line 615 of file FeatureVector.cpp.
References begin(), and end().
Definition at line 581 of file FeatureVector.cpp.
References begin(), end(), and resize().
Definition at line 133 of file FeatureVector.h.
bool Moses::FVector::operator== | ( | const FVector & | rhs | ) | const |
Equality
Definition at line 233 of file FeatureVector.cpp.
References cbegin(), and cend().
FValue Moses::FVector::operator[] | ( | size_t | index | ) | const |
Definition at line 277 of file FeatureVector.cpp.
Definition at line 272 of file FeatureVector.cpp.
FValue & Moses::FVector::operator[] | ( | size_t | index | ) |
Equivalent for core features.
Definition at line 266 of file FeatureVector.cpp.
ProxyFVector Moses::FVector::operator[] | ( | const FName & | name | ) |
std::ostream& Moses::FVector::print | ( | std::ostream & | out | ) | const |
void Moses::FVector::printCoreFeatures | ( | ) |
additional
Definition at line 357 of file FeatureVector.cpp.
Referenced by Moses::ScoreComponentCollection::PrintCoreFeatures().
void Moses::FVector::printSparseFearFeatureCounts | ( | ) |
Definition at line 433 of file FeatureVector.cpp.
References cbegin(), cend(), and Moses::FName::getFearIdCount().
void Moses::FVector::printSparseFearFeatureCounts | ( | std::ofstream & | out | ) |
Definition at line 421 of file FeatureVector.cpp.
References cbegin(), cend(), and Moses::FName::getFearIdCount().
Referenced by Moses::ScoreComponentCollection::PrintSparseFearFeatureCounts().
void Moses::FVector::printSparseHopeFeatureCounts | ( | ) |
Definition at line 427 of file FeatureVector.cpp.
References cbegin(), cend(), and Moses::FName::getHopeIdCount().
void Moses::FVector::printSparseHopeFeatureCounts | ( | std::ofstream & | out | ) |
Definition at line 415 of file FeatureVector.cpp.
References cbegin(), cend(), and Moses::FName::getHopeIdCount().
Referenced by Moses::ScoreComponentCollection::PrintSparseHopeFeatureCounts().
size_t Moses::FVector::pruneSparseFeatures | ( | size_t | threshold | ) |
Definition at line 439 of file FeatureVector.cpp.
References cbegin(), cend(), count, Moses::FName::eraseId(), Moses::FName::getFearIdCount(), Moses::FName::getHopeIdCount(), and Moses::FName::getId().
Referenced by Moses::ScoreComponentCollection::PruneSparseFeatures().
size_t Moses::FVector::pruneZeroWeightFeatures | ( | ) |
Definition at line 459 of file FeatureVector.cpp.
References cbegin(), cend(), count, Moses::FName::eraseId(), and Moses::FName::getId().
Referenced by Moses::ScoreComponentCollection::PruneZeroWeightFeatures().
void Moses::FVector::resize | ( | size_t | newsize | ) |
Definition at line 167 of file FeatureVector.cpp.
Referenced by corePlusEquals(), multiplyEqualsBackoff(), operator*=(), operator+=(), operator-=(), operator/=(), and Moses::ScoreComponentCollection::Resize().
void Moses::FVector::save | ( | const std::string & | filename | ) | const |
void Moses::FVector::setToBinaryOf | ( | const FVector & | rhs | ) |
Definition at line 519 of file FeatureVector.cpp.
References cbegin(), and cend().
Referenced by Moses::ScoreComponentCollection::SetToBinaryOf().
size_t Moses::FVector::size | ( | ) | const [inline] |
Size
Definition at line 179 of file FeatureVector.h.
Referenced by BOOST_AUTO_TEST_CASE(), Moses::inner_product(), l1regularize(), Moses::ScoreComponentCollection::Size(), and sparseL1regularize().
size_t Moses::FVector::sparseL1regularize | ( | float | lambda | ) |
Definition at line 745 of file FeatureVector.cpp.
References begin(), end(), Moses::FName::eraseId(), Moses::FName::getId(), and size().
Referenced by Moses::ScoreComponentCollection::SparseL1Regularize().
void Moses::FVector::sparseL2regularize | ( | float | lambda | ) |
Definition at line 784 of file FeatureVector.cpp.
References begin(), and end().
Referenced by Moses::ScoreComponentCollection::SparseL2Regularize().
void Moses::FVector::sparsePlusEquals | ( | const FVector & | rhs | ) |
Definition at line 381 of file FeatureVector.cpp.
References cbegin(), and cend().
Referenced by Moses::ScoreComponentCollection::SparsePlusEquals().
FValue Moses::FVector::sum | ( | ) | const |
Definition at line 795 of file FeatureVector.cpp.
References cbegin(), and cend().
Referenced by BOOST_AUTO_TEST_CASE().
void Moses::FVector::thresholdScale | ( | float | maxValue | ) |
Definition at line 326 of file FeatureVector.cpp.
References cbegin(), cend(), and operator*=().
Referenced by Moses::ScoreComponentCollection::ThresholdScaling().
void Moses::FVector::updateConfidenceCounts | ( | const FVector & | weightUpdate, | |
bool | signedCounts | |||
) |
Definition at line 479 of file FeatureVector.cpp.
References cbegin(), and cend().
Referenced by Moses::ScoreComponentCollection::UpdateConfidenceCounts().
void Moses::FVector::updateLearningRates | ( | float | decay_core, | |
float | decay_sparse, | |||
const FVector & | confidence_counts, | |||
float | core_r0, | |||
float | sparse_r0 | |||
) |
Definition at line 506 of file FeatureVector.cpp.
References cbegin(), and cend().
Referenced by Moses::ScoreComponentCollection::UpdateLearningRates().
void Moses::FVector::write | ( | std::ostream & | out, | |
const std::string & | sep = " " , |
|||
const std::string & | linesep = "\n" | |||
) | const |
friend class ProxyFVector [friend] |
Definition at line 315 of file FeatureVector.h.