Moses::FVector Class Reference

#include <FeatureVector.h>

List of all members.

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)
FVectoroperator= (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)
FValueoperator[] (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
FVectoroperator+= (const FVector &rhs)
FVectoroperator-= (const FVector &rhs)
FVectoroperator*= (const FVector &rhs)
FVectoroperator/= (const FVector &rhs)
FVectoroperator*= (const FValue &rhs)
FVectoroperator/= (const FValue &rhs)
FVectormultiplyEqualsBackoff (const FVector &rhs, float backoff)
FVectormultiplyEquals (float core_r0, float sparse_r0)
FVectormax_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)
FVectorcoreDivideEquals (float scalar)
FVectordivideEquals (const FVector &rhs)
void merge (const FVector &other)

Friends

class ProxyFVector
void swap (FVector &first, FVector &second)


Detailed Description

A sparse feature (or weight) vector.

Definition at line 127 of file FeatureVector.h.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

Moses::FVector::FVector ( size_t  coreFeatures = 0  ) 

Empty feature vector

Definition at line 165 of file FeatureVector.cpp.


Member Function Documentation

iterator Moses::FVector::begin (  )  [inline]

Definition at line 148 of file FeatureVector.h.

Referenced by l1regularize(), l2regularize(), multiplyEquals(), multiplyEqualsBackoff(), operator*=(), operator/=(), sparseL1regularize(), and sparseL2regularize().

Here is the caller graph for this function:

void Moses::FVector::capMax ( FValue  maxValue  ) 

Definition at line 338 of file FeatureVector.cpp.

References cbegin(), and cend().

Referenced by Moses::ScoreComponentCollection::CapMax().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::FVector::capMin ( FValue  minValue  ) 

Definition at line 345 of file FeatureVector.cpp.

References cbegin(), and cend().

Referenced by Moses::ScoreComponentCollection::CapMin().

Here is the call graph for this function:

Here is the caller graph for this function:

const_iterator Moses::FVector::cbegin (  )  const [inline]

const_iterator Moses::FVector::cend (  )  const [inline]

void Moses::FVector::clear (  ) 

Definition at line 176 of file FeatureVector.cpp.

Referenced by load(), and Moses::ScoreComponentCollection::ZeroAll().

Here is the caller graph for this function:

void Moses::FVector::coreAssign ( const FVector rhs  ) 

Definition at line 397 of file FeatureVector.cpp.

Referenced by Moses::ScoreComponentCollection::CoreAssign().

Here is the caller graph for this function:

FVector & Moses::FVector::coreDivideEquals ( float  scalar  ) 

Definition at line 529 of file FeatureVector.cpp.

Referenced by Moses::ScoreComponentCollection::CoreDivideEquals().

Here is the caller graph for this function:

void Moses::FVector::corePlusEquals ( const FVector rhs  ) 

Definition at line 388 of file FeatureVector.cpp.

References resize().

Referenced by Moses::ScoreComponentCollection::CorePlusEquals().

Here is the call graph for this function:

Here is the caller graph for this function:

size_t Moses::FVector::coreSize (  )  const [inline]

Definition at line 183 of file FeatureVector.h.

Referenced by Moses::ScoreComponentCollection::Resize().

Here is the caller graph for this function:

FVector & Moses::FVector::divideEquals ( const FVector rhs  ) 

Definition at line 537 of file FeatureVector.cpp.

References cbegin(), and cend().

Referenced by Moses::ScoreComponentCollection::DivideEquals().

Here is the call graph for this function:

Here is the caller graph for this function:

iterator Moses::FVector::end (  )  [inline]

Definition at line 151 of file FeatureVector.h.

Referenced by l1regularize(), l2regularize(), multiplyEquals(), multiplyEqualsBackoff(), operator*=(), operator/=(), sparseL1regularize(), and sparseL2regularize().

Here is the caller graph for this function:

const std::valarray<FValue>& Moses::FVector::getCoreFeatures (  )  const [inline]

Definition at line 187 of file FeatureVector.h.

Referenced by Moses::ScoreComponentCollection::getCoreFeatures().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::FVector::incrementSparseHopeFeatures (  ) 

Definition at line 403 of file FeatureVector.cpp.

References cbegin(), cend(), and Moses::FName::incrementHopeId().

Referenced by Moses::ScoreComponentCollection::IncrementSparseHopeFeatures().

Here is the call graph for this function:

Here is the caller graph for this function:

FValue Moses::FVector::inner_product ( const FVector rhs  )  const

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

FValue Moses::FVector::l1norm_coreFeatures (  )  const

Definition at line 666 of file FeatureVector.cpp.

Referenced by Moses::ScoreComponentCollection::L1Normalise().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::FVector::l2regularize ( float  lambda  ) 

Definition at line 734 of file FeatureVector.cpp.

References begin(), and end().

Referenced by Moses::ScoreComponentCollection::L2Regularize().

Here is the call graph for this function:

Here is the caller graph for this function:

FValue Moses::FVector::linfnorm (  )  const

Definition at line 680 of file FeatureVector.cpp.

References cbegin(), and cend().

Referenced by Moses::ScoreComponentCollection::GetLInfNorm().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

FVector& Moses::FVector::max_equals ( const FVector rhs  ) 

void Moses::FVector::merge ( const FVector other  ) 

Definition at line 818 of file FeatureVector.cpp.

Referenced by Moses::ScoreComponentCollection::Merge().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

FVector & Moses::FVector::multiplyEqualsBackoff ( const FVector rhs,
float  backoff 
)

Definition at line 624 of file FeatureVector.cpp.

References begin(), end(), and resize().

Referenced by Moses::ScoreComponentCollection::MultiplyEqualsBackoff().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Moses::FVector::operator!= ( const FVector rhs  )  const

Definition at line 253 of file FeatureVector.cpp.

FVector & Moses::FVector::operator*= ( const FValue rhs  ) 

Definition at line 605 of file FeatureVector.cpp.

References begin(), and end().

Here is the call graph for this function:

FVector & Moses::FVector::operator*= ( const FVector rhs  ) 

Definition at line 561 of file FeatureVector.cpp.

References begin(), end(), and resize().

Referenced by thresholdScale().

Here is the call graph for this function:

Here is the caller graph for this function:

FVector & Moses::FVector::operator+= ( const FVector rhs  ) 

arithmetic

Definition at line 369 of file FeatureVector.cpp.

References cbegin(), cend(), and resize().

Here is the call graph for this function:

FVector & Moses::FVector::operator-= ( const FVector rhs  ) 

Definition at line 547 of file FeatureVector.cpp.

References cbegin(), cend(), and resize().

Here is the call graph for this function:

FVector & Moses::FVector::operator/= ( const FValue rhs  ) 

Definition at line 615 of file FeatureVector.cpp.

References begin(), and end().

Here is the call graph for this function:

FVector & Moses::FVector::operator/= ( const FVector rhs  ) 

Definition at line 581 of file FeatureVector.cpp.

References begin(), end(), and resize().

Here is the call graph for this function:

FVector& Moses::FVector::operator= ( const FVector rhs  )  [inline]

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().

Here is the call graph for this function:

FValue Moses::FVector::operator[] ( size_t  index  )  const

Definition at line 277 of file FeatureVector.cpp.

FValue Moses::FVector::operator[] ( const FName name  )  const

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  ) 

Element access

Definition at line 258 of file FeatureVector.cpp.

References ProxyFVector.

std::ostream& Moses::FVector::print ( std::ostream &  out  )  const

pretty printing

Referenced by Moses::operator<<().

Here is the caller graph for this function:

void Moses::FVector::printCoreFeatures (  ) 

additional

Definition at line 357 of file FeatureVector.cpp.

Referenced by Moses::ScoreComponentCollection::PrintCoreFeatures().

Here is the caller graph for this function:

void Moses::FVector::printSparseFearFeatureCounts (  ) 

Definition at line 433 of file FeatureVector.cpp.

References cbegin(), cend(), and Moses::FName::getFearIdCount().

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::FVector::printSparseHopeFeatureCounts (  ) 

Definition at line 427 of file FeatureVector.cpp.

References cbegin(), cend(), and Moses::FName::getHopeIdCount().

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::FVector::sparseL2regularize ( float  lambda  ) 

Definition at line 784 of file FeatureVector.cpp.

References begin(), and end().

Referenced by Moses::ScoreComponentCollection::SparseL2Regularize().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::FVector::sparsePlusEquals ( const FVector rhs  ) 

Definition at line 381 of file FeatureVector.cpp.

References cbegin(), and cend().

Referenced by Moses::ScoreComponentCollection::SparsePlusEquals().

Here is the call graph for this function:

Here is the caller graph for this function:

FValue Moses::FVector::sum (  )  const

Definition at line 795 of file FeatureVector.cpp.

References cbegin(), and cend().

Referenced by BOOST_AUTO_TEST_CASE().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::FVector::thresholdScale ( float  maxValue  ) 

Definition at line 326 of file FeatureVector.cpp.

References cbegin(), cend(), and operator*=().

Referenced by Moses::ScoreComponentCollection::ThresholdScaling().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::FVector::write ( std::ostream &  out,
const std::string &  sep = " ",
const std::string &  linesep = "\n" 
) const


Friends And Related Function Documentation

friend class ProxyFVector [friend]

Definition at line 197 of file FeatureVector.h.

Referenced by operator[]().

void swap ( FVector first,
FVector second 
) [friend]

Definition at line 315 of file FeatureVector.h.


The documentation for this class was generated from the following files:

Generated on Thu Jul 6 00:33:00 2017 for Moses by  doxygen 1.5.9