private static Counter<String> loadWeights(String wtsInitialFile,boolean uniformStartWeights,boolean randomizeStartWeights,TranslationModel<IString,String> translationModel){
  Counter<String> weights=IOTools.readWeights(wtsInitialFile);
  if (weights == null)   weights=new ClassicCounter<>();
  if (uniformStartWeights) {
    Set<String> featureNames=new HashSet<>(weights.keySet());
    featureNames.addAll(FeatureUtils.getBaselineFeatures(translationModel));
    for (    String key : featureNames) {
      if (key.startsWith(NGramLanguageModelFeaturizer.DEFAULT_FEATURE_NAME)) {
        weights.setCount(key,0.5);
      }
 else       if (key.startsWith(WordPenaltyFeaturizer.FEATURE_NAME)) {
        weights.setCount(key,-1.0);
      }
 else {
        weights.setCount(key,0.2);
      }
    }
  }
  if (randomizeStartWeights) {
    double scale=1e-4;
    OptimizerUtils.randomizeWeightsInPlace(weights,scale);
  }
  return weights;
}

private static Counter < String > loadWeights ( String wtsInitialFile , boolean uniformStartWeights , boolean randomizeStartWeights , TranslationModel < IString , String > translationModel ) { Counter < String > weights = IOTools . readWeights ( wtsInitialFile ) ; if ( weights == null ) weights = new ClassicCounter < > ( ) ; if ( uniformStartWeights ) { Set < String > featureNames = new HashSet < > ( weights . keySet ( ) ) ; featureNames . addAll ( FeatureUtils . getBaselineFeatures ( translationModel ) ) ; for ( String key : featureNames ) { if ( key . startsWith ( NGramLanguageModelFeaturizer . DEFAULT_FEATURE_NAME ) ) { weights . setCount ( key , 0.5 ) ; } else if ( key . startsWith ( WordPenaltyFeaturizer . FEATURE_NAME ) ) { weights . setCount ( key , - 1.0 ) ; } else { weights . setCount ( key , 0.2 ) ; } } } if ( randomizeStartWeights ) { double scale = 1e-4 ; OptimizerUtils . randomizeWeightsInPlace ( weights , scale ) ; } return weights ; }
configure weights stored on file .
