00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MAIN_H_
00020 #define MAIN_H_
00021
00022 #include <vector>
00023
00024 #include "moses/ScoreComponentCollection.h"
00025 #include "moses/Word.h"
00026 #include "moses/FF/FeatureFunction.h"
00027 #include "Decoder.h"
00028
00029 typedef std::map<const Moses::FeatureFunction*, std::vector< float > > ProducerWeightMap;
00030 typedef std::pair<const Moses::FeatureFunction*, std::vector< float > > ProducerWeightPair;
00031
00032 template <class T> bool from_string(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&))
00033 {
00034 std::istringstream iss(s);
00035 return !(iss >> f >> t).fail();
00036 }
00037
00038 struct RandomIndex {
00039 ptrdiff_t operator()(ptrdiff_t max) {
00040 srand(time(0));
00041 return static_cast<ptrdiff_t> (rand() % max);
00042 }
00043 };
00044
00045
00046 bool loadSentences(const std::string& filename, std::vector<std::string>& sentences);
00047 bool evaluateModulo(size_t shard_position, size_t mix_or_dump_base, size_t actual_batch_size);
00048 void printFeatureValues(std::vector<std::vector<Moses::ScoreComponentCollection> > &featureValues);
00049 void ignoreCoreFeatures(std::vector<std::vector<Moses::ScoreComponentCollection> > &featureValues, ProducerWeightMap &coreWeightMap);
00050 void takeLogs(std::vector<std::vector<Moses::ScoreComponentCollection> > &featureValues, size_t base);
00051 void deleteTranslations(std::vector<std::vector<const Moses::Word*> > &translations);
00052 void decodeHopeOrFear(size_t rank, size_t size, size_t decode, std::string decode_filename, std::vector<std::string> &inputSentences, Mira::MosesDecoder* decoder, size_t n, float bleuWeight);
00053 void applyLearningRates(std::vector<std::vector<Moses::ScoreComponentCollection> > &featureValues, float core_r0, float sparse_r0);
00054 void applyPerFeatureLearningRates(std::vector<std::vector<Moses::ScoreComponentCollection> > &featureValues, Moses::ScoreComponentCollection featureLearningRates, float sparse_r0);
00055 void scaleFeatureScore(const Moses::FeatureFunction *sp, float scaling_factor, std::vector<std::vector<Moses::ScoreComponentCollection> > &featureValues, size_t rank, size_t epoch);
00056 void scaleFeatureScores(const Moses::FeatureFunction *sp, float scaling_factor, std::vector<std::vector<Moses::ScoreComponentCollection> > &featureValues, size_t rank, size_t epoch);
00057
00058 #endif