public void doTraining() throws IOException { readTrainingSentences(examplesFilename); constructLabelVocab(); extractFeatures(); model.lockdownAfterFeatureExtraction(); if (modelLoadFilename != null) { readWarmStartModel(); } optimizationLoop(); model.saveModelAsText(modelSaveFilename); }
public void optimizationLoop() { OWLQN minimizer = new OWLQN(); minimizer.setMaxIters(maxIter); minimizer.setQuiet(false); minimizer.setWeightsPrinting(new MyWeightsPrinter()); double[] initialWeights = model.convertCoefsToFlat(); double[] finalWeights = minimizer.minimize(new GradientCalculator(), initialWeights, l1penalty, tol, 5); model.setCoefsFromFlat(finalWeights); }
public void constructLabelVocab() { for (Sentence s : lSentences) { for (String l : s.labels) { model.labelVocab.num(l); } } model.labelVocab.lock(); model.numLabels = model.labelVocab.size(); }
public void readWarmStartModel() throws IOException { assert model.featureVocab.isLocked(); Model warmModel = Model.loadModelFromText(modelLoadFilename); Model.copyCoefsForIntersectingFeatures(warmModel, model); }