mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-05 19:23:13 +03:00
add parameter --ignore-u-weight
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/branches/mira-mtm5@3773 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
parent
fbc8910102
commit
54824d132f
@ -103,7 +103,8 @@ namespace Mira {
|
|||||||
vector< ScoreComponentCollection>& featureValues,
|
vector< ScoreComponentCollection>& featureValues,
|
||||||
vector< float>& bleuScores,
|
vector< float>& bleuScores,
|
||||||
bool oracle,
|
bool oracle,
|
||||||
bool distinct)
|
bool distinct,
|
||||||
|
bool ignoreUWeight)
|
||||||
{
|
{
|
||||||
StaticData &staticData = StaticData::InstanceNonConst();
|
StaticData &staticData = StaticData::InstanceNonConst();
|
||||||
|
|
||||||
@ -142,9 +143,25 @@ namespace Mira {
|
|||||||
//std::cout << "Score breakdown: " << path.GetScoreBreakdown() << endl;
|
//std::cout << "Score breakdown: " << path.GetScoreBreakdown() << endl;
|
||||||
float scoreWithoutBleu = path.GetTotalScore() - bleuObjectiveWeight * bleuScore;
|
float scoreWithoutBleu = path.GetTotalScore() - bleuObjectiveWeight * bleuScore;
|
||||||
cerr << "Total score: " << path.GetTotalScore() << ", Score w/o bleu: " << scoreWithoutBleu << ", Bleu: " << bleuScore << endl;
|
cerr << "Total score: " << path.GetTotalScore() << ", Score w/o bleu: " << scoreWithoutBleu << ", Bleu: " << bleuScore << endl;
|
||||||
|
//if (distinct) {
|
||||||
|
Phrase bestPhrase = path.GetTargetPhrase();
|
||||||
|
|
||||||
|
for (size_t pos = 0; pos < bestPhrase.GetSize(); ++pos) {
|
||||||
|
const Word &word = bestPhrase.GetWord(pos);
|
||||||
|
Word *newWord = new Word(word);
|
||||||
|
cerr << *newWord << " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
cerr << endl;
|
||||||
|
//}
|
||||||
|
|
||||||
// set bleu score to zero in the feature vector since we do not want to optimise its weight
|
// set bleu score to zero in the feature vector since we do not want to optimise its weight
|
||||||
setBleuScore(featureValues.back(), 0);
|
setBleuScore(featureValues.back(), 0);
|
||||||
|
|
||||||
|
if (ignoreUWeight) {
|
||||||
|
const UnknownWordPenaltyProducer *unknownWPP = (const_cast<TranslationSystem&>(system)).GetUnknownWordPenaltyProducer();
|
||||||
|
(featureValues.back()).Assign(unknownWPP, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the best
|
// get the best
|
||||||
|
@ -61,7 +61,8 @@ class MosesDecoder {
|
|||||||
std::vector< Moses::ScoreComponentCollection>& featureValues,
|
std::vector< Moses::ScoreComponentCollection>& featureValues,
|
||||||
std::vector< float>& scores,
|
std::vector< float>& scores,
|
||||||
bool oracle,
|
bool oracle,
|
||||||
bool distinct);
|
bool distinct,
|
||||||
|
bool ignoreUWeight);
|
||||||
size_t getCurrentInputLength();
|
size_t getCurrentInputLength();
|
||||||
void updateHistory(const std::vector<const Moses::Word*>& words);
|
void updateHistory(const std::vector<const Moses::Word*>& words);
|
||||||
void updateHistory(const std::vector< std::vector< const Moses::Word*> >& words, std::vector<size_t>& sourceLengths, std::vector<size_t>& ref_ids);
|
void updateHistory(const std::vector< std::vector< const Moses::Word*> >& words, std::vector<size_t>& sourceLengths, std::vector<size_t>& ref_ids);
|
||||||
|
@ -98,6 +98,7 @@ int main(int argc, char** argv) {
|
|||||||
bool accumulateMostViolatedConstraints;
|
bool accumulateMostViolatedConstraints;
|
||||||
bool pastAndCurrentConstraints;
|
bool pastAndCurrentConstraints;
|
||||||
bool suppressConvergence;
|
bool suppressConvergence;
|
||||||
|
bool ignoreUWeight;
|
||||||
float clipping;
|
float clipping;
|
||||||
bool fixedClipping;
|
bool fixedClipping;
|
||||||
po::options_description desc("Allowed options");
|
po::options_description desc("Allowed options");
|
||||||
@ -130,6 +131,7 @@ int main(int argc, char** argv) {
|
|||||||
("accumulate-most-violated-constraints", po::value<bool>(&accumulateMostViolatedConstraints)->default_value(false), "Accumulate most violated constraint per example")
|
("accumulate-most-violated-constraints", po::value<bool>(&accumulateMostViolatedConstraints)->default_value(false), "Accumulate most violated constraint per example")
|
||||||
("past-and-current-constraints", po::value<bool>(&pastAndCurrentConstraints)->default_value(false), "Accumulate most violated constraint per example and use them along all current constraints")
|
("past-and-current-constraints", po::value<bool>(&pastAndCurrentConstraints)->default_value(false), "Accumulate most violated constraint per example and use them along all current constraints")
|
||||||
("suppress-convergence", po::value<bool>(&suppressConvergence)->default_value(false), "Suppress convergence, fixed number of epochs")
|
("suppress-convergence", po::value<bool>(&suppressConvergence)->default_value(false), "Suppress convergence, fixed number of epochs")
|
||||||
|
("ignore-u-weight", po::value<bool>(&ignoreUWeight)->default_value(false), "Don't tune unknown word penalty weight")
|
||||||
("clipping", po::value<float>(&clipping)->default_value(0.01f), "Set a threshold to regularise updates")
|
("clipping", po::value<float>(&clipping)->default_value(0.01f), "Set a threshold to regularise updates")
|
||||||
("fixed-clipping", po::value<bool>(&fixedClipping)->default_value(false), "Use a fixed clipping threshold");
|
("fixed-clipping", po::value<bool>(&fixedClipping)->default_value(false), "Use a fixed clipping threshold");
|
||||||
|
|
||||||
@ -228,6 +230,7 @@ int main(int argc, char** argv) {
|
|||||||
cerr << "Add only violated constraints? " << onlyViolatedConstraints << endl;
|
cerr << "Add only violated constraints? " << onlyViolatedConstraints << endl;
|
||||||
cerr << "Using slack? " << slack << endl;
|
cerr << "Using slack? " << slack << endl;
|
||||||
cerr << "BP factor: " << BPfactor << endl;
|
cerr << "BP factor: " << BPfactor << endl;
|
||||||
|
cerr << "Ignore unknown word penalty? " << ignoreUWeight << endl;
|
||||||
cerr << "Fixed clipping? " << fixedClipping << endl;
|
cerr << "Fixed clipping? " << fixedClipping << endl;
|
||||||
cerr << "clipping: " << clipping << endl;
|
cerr << "clipping: " << clipping << endl;
|
||||||
if (learner == "mira") {
|
if (learner == "mira") {
|
||||||
@ -314,7 +317,8 @@ int main(int argc, char** argv) {
|
|||||||
featureValues[batchPosition],
|
featureValues[batchPosition],
|
||||||
bleuScores[batchPosition],
|
bleuScores[batchPosition],
|
||||||
true,
|
true,
|
||||||
distinctNbest);
|
distinctNbest,
|
||||||
|
ignoreUWeight);
|
||||||
inputLengths.push_back(decoder->getCurrentInputLength());
|
inputLengths.push_back(decoder->getCurrentInputLength());
|
||||||
ref_ids.push_back(*sid);
|
ref_ids.push_back(*sid);
|
||||||
decoder->cleanup();
|
decoder->cleanup();
|
||||||
@ -337,7 +341,8 @@ int main(int argc, char** argv) {
|
|||||||
featureValues[batchPosition],
|
featureValues[batchPosition],
|
||||||
bleuScores[batchPosition],
|
bleuScores[batchPosition],
|
||||||
true,
|
true,
|
||||||
distinctNbest);
|
distinctNbest,
|
||||||
|
ignoreUWeight);
|
||||||
decoder->cleanup();
|
decoder->cleanup();
|
||||||
oracles.push_back(oracle);
|
oracles.push_back(oracle);
|
||||||
cerr << "Rank " << rank << ": ";
|
cerr << "Rank " << rank << ": ";
|
||||||
@ -363,7 +368,8 @@ int main(int argc, char** argv) {
|
|||||||
featureValues[batchPosition],
|
featureValues[batchPosition],
|
||||||
bleuScores[batchPosition],
|
bleuScores[batchPosition],
|
||||||
true,
|
true,
|
||||||
distinctNbest);
|
distinctNbest,
|
||||||
|
ignoreUWeight);
|
||||||
decoder->cleanup();
|
decoder->cleanup();
|
||||||
cerr << "Rank " << rank << ": ";
|
cerr << "Rank " << rank << ": ";
|
||||||
for (size_t i = 0; i < fear.size(); ++i) {
|
for (size_t i = 0; i < fear.size(); ++i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user