mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-19 23:27:46 +03:00
print feature counts to file
This commit is contained in:
parent
03d3cb6a7a
commit
0a537a9f58
@ -606,8 +606,10 @@ int main(int argc, char** argv) {
|
||||
|
||||
string f1 = "decode_hope_epoch0";
|
||||
string f2 = "decode_fear_epoch0";
|
||||
string s1 = "sparse_feature_hope_counts";
|
||||
ofstream hopePlusFeatures(f1.c_str());
|
||||
ofstream fearPlusFeatures(f2.c_str());
|
||||
ofstream sparseFeatureCounts(s1.c_str());
|
||||
if (!hopePlusFeatures || !fearPlusFeatures) {
|
||||
ostringstream msg;
|
||||
msg << "Unable to open file";
|
||||
@ -1362,7 +1364,8 @@ int main(int argc, char** argv) {
|
||||
|
||||
if (weightEpochDump == weightDumpFrequency && printFeatureInfo) {
|
||||
// print out all features with counts
|
||||
mixedAverageWeights.PrintSparseFeatureCounts();
|
||||
mixedAverageWeights.PrintSparseFeatureCounts(sparseFeatureCounts);
|
||||
sparseFeatureCounts.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -323,9 +323,9 @@ namespace Moses {
|
||||
FName::incrementId((i->first).name());
|
||||
}
|
||||
|
||||
void FVector::printSparseFeatureCounts() {
|
||||
void FVector::printSparseFeatureCounts(std::ofstream& out) {
|
||||
for (const_iterator i = cbegin(); i != cend(); ++i)
|
||||
std::cerr << (i->first).name() << ": " << FName::getIdCount((i->first).name()) << std::endl;
|
||||
out << (i->first).name() << ": " << FName::getIdCount((i->first).name()) << std::endl;
|
||||
}
|
||||
|
||||
size_t FVector::pruneSparseFeatures(size_t threshold) {
|
||||
|
@ -202,7 +202,7 @@ namespace Moses {
|
||||
void sparsePlusEquals(const FVector& rhs);
|
||||
|
||||
void incrementSparseFeatures();
|
||||
void printSparseFeatureCounts();
|
||||
void printSparseFeatureCounts(std::ofstream& out);
|
||||
size_t pruneSparseFeatures(size_t threshold);
|
||||
size_t pruneZeroWeightFeatures();
|
||||
|
||||
|
@ -365,7 +365,7 @@ public:
|
||||
void Save(std::ostream&) const;
|
||||
|
||||
void IncrementSparseFeatures() { m_scores.incrementSparseFeatures(); }
|
||||
void PrintSparseFeatureCounts() { m_scores.printSparseFeatureCounts(); }
|
||||
void PrintSparseFeatureCounts(std::ofstream& out) { m_scores.printSparseFeatureCounts(out); }
|
||||
size_t PruneSparseFeatures(size_t threshold) { return m_scores.pruneSparseFeatures(threshold); }
|
||||
size_t PruneZeroWeightFeatures() { return m_scores.pruneZeroWeightFeatures(); }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user