private void copyStatesAndWeightsFrom (CRF initialCRF) { this.parameters = new Factors (initialCRF.parameters, true); // This will copy all the transition weights this.parameters.weightAlphabet = (Alphabet) initialCRF.parameters.weightAlphabet.clone(); //weightAlphabet = (Alphabet) initialCRF.weightAlphabet.clone (); //weights = new SparseVector [initialCRF.weights.length]; states.clear (); // Clear these, because they will be filled by this.addState() this.parameters.initialWeights = new double[0]; this.parameters.finalWeights = new double[0]; for (int i = 0; i < initialCRF.states.size(); i++) { State s = (State) initialCRF.getState (i); String[][] weightNames = new String[s.weightsIndices.length][]; for (int j = 0; j < weightNames.length; j++) { int[] thisW = s.weightsIndices[j]; weightNames[j] = (String[]) initialCRF.parameters.weightAlphabet.lookupObjects(thisW, new String [s.weightsIndices[j].length]); } addState (s.name, initialCRF.parameters.initialWeights[i], initialCRF.parameters.finalWeights[i], s.destinationNames, s.labels, weightNames); } featureSelections = initialCRF.featureSelections.clone (); // yyy weightsFrozen = (boolean[]) initialCRF.weightsFrozen.clone(); }
/** Construct new Factors by copying the other one. */ public Factors (Factors other, boolean cloneAlphabet) { weightAlphabet = cloneAlphabet ? (Alphabet) other.weightAlphabet.clone() : other.weightAlphabet; weights = new SparseVector[other.weights.length]; for (int i = 0; i < weights.length; i++) weights[i] = (SparseVector) other.weights[i].cloneMatrix(); defaultWeights = other.defaultWeights.clone(); weightsFrozen = other.weightsFrozen; initialWeights = other.initialWeights.clone(); finalWeights = other.finalWeights.clone(); }
/** Construct new Factors by copying the other one. */ public Factors (Factors other, boolean cloneAlphabet) { weightAlphabet = cloneAlphabet ? (Alphabet) other.weightAlphabet.clone() : other.weightAlphabet; weights = new SparseVector[other.weights.length]; for (int i = 0; i < weights.length; i++) weights[i] = (SparseVector) other.weights[i].cloneMatrix(); defaultWeights = other.defaultWeights.clone(); weightsFrozen = other.weightsFrozen; initialWeights = other.initialWeights.clone(); finalWeights = other.finalWeights.clone(); }
/** Construct new Factors by copying the other one. */ public Factors (Factors other, boolean cloneAlphabet) { weightAlphabet = cloneAlphabet ? (Alphabet) other.weightAlphabet.clone() : other.weightAlphabet; weights = new SparseVector[other.weights.length]; for (int i = 0; i < weights.length; i++) weights[i] = (SparseVector) other.weights[i].cloneMatrix(); defaultWeights = other.defaultWeights.clone(); weightsFrozen = other.weightsFrozen; initialWeights = other.initialWeights.clone(); finalWeights = other.finalWeights.clone(); }
private void copyStatesAndWeightsFrom (CRF initialCRF) { this.parameters = new Factors (initialCRF.parameters, true); // This will copy all the transition weights this.parameters.weightAlphabet = (Alphabet) initialCRF.parameters.weightAlphabet.clone(); //weightAlphabet = (Alphabet) initialCRF.weightAlphabet.clone (); //weights = new SparseVector [initialCRF.weights.length]; states.clear (); // Clear these, because they will be filled by this.addState() this.parameters.initialWeights = new double[0]; this.parameters.finalWeights = new double[0]; for (int i = 0; i < initialCRF.states.size(); i++) { State s = (State) initialCRF.getState (i); String[][] weightNames = new String[s.weightsIndices.length][]; for (int j = 0; j < weightNames.length; j++) { int[] thisW = s.weightsIndices[j]; weightNames[j] = (String[]) initialCRF.parameters.weightAlphabet.lookupObjects(thisW, new String [s.weightsIndices[j].length]); } addState (s.name, initialCRF.parameters.initialWeights[i], initialCRF.parameters.finalWeights[i], s.destinationNames, s.labels, weightNames); } featureSelections = initialCRF.featureSelections.clone (); // yyy weightsFrozen = (boolean[]) initialCRF.weightsFrozen.clone(); }
private void copyStatesAndWeightsFrom (CRF initialCRF) { this.parameters = new Factors (initialCRF.parameters, true); // This will copy all the transition weights this.parameters.weightAlphabet = (Alphabet) initialCRF.parameters.weightAlphabet.clone(); //weightAlphabet = (Alphabet) initialCRF.weightAlphabet.clone (); //weights = new SparseVector [initialCRF.weights.length]; states.clear (); // Clear these, because they will be filled by this.addState() this.parameters.initialWeights = new double[0]; this.parameters.finalWeights = new double[0]; for (int i = 0; i < initialCRF.states.size(); i++) { State s = (State) initialCRF.getState (i); String[][] weightNames = new String[s.weightsIndices.length][]; for (int j = 0; j < weightNames.length; j++) { int[] thisW = s.weightsIndices[j]; weightNames[j] = (String[]) initialCRF.parameters.weightAlphabet.lookupObjects(thisW, new String [s.weightsIndices[j].length]); } addState (s.name, initialCRF.parameters.initialWeights[i], initialCRF.parameters.finalWeights[i], s.destinationNames, s.labels, weightNames); } featureSelections = initialCRF.featureSelections.clone (); // yyy weightsFrozen = (boolean[]) initialCRF.weightsFrozen.clone(); }
public AddClassifierTokenPredictions(TokenClassifiers tokenClassifiers, int[] predRanks2add, boolean binary, InstanceList testList) { m_predRanks2add = predRanks2add; m_binary = binary; m_tokenClassifiers = tokenClassifiers; m_inProduction = false; m_dataAlphabet = (Alphabet) tokenClassifiers.getAlphabet().clone(); Alphabet labelAlphabet = tokenClassifiers.getLabelAlphabet(); // add the token prediction features to the alphabet for (int i = 0; i < m_predRanks2add.length; i++) { for (int j = 0; j < labelAlphabet.size(); j++) { String featName = "TOK_PRED=" + labelAlphabet.lookupObject(j).toString() + "_@_RANK_" + m_predRanks2add[i]; m_dataAlphabet.lookupIndex(featName, true); } } // evaluate token classifier if (testList != null) { Trial trial = new Trial(m_tokenClassifiers, testList); logger.info("Token classifier accuracy on test set = " + trial.getAccuracy()); } }
public AddClassifierTokenPredictions(TokenClassifiers tokenClassifiers, int[] predRanks2add, boolean binary, InstanceList testList) { m_predRanks2add = predRanks2add; m_binary = binary; m_tokenClassifiers = tokenClassifiers; m_inProduction = false; m_dataAlphabet = (Alphabet) tokenClassifiers.getAlphabet().clone(); Alphabet labelAlphabet = tokenClassifiers.getLabelAlphabet(); // add the token prediction features to the alphabet for (int i = 0; i < m_predRanks2add.length; i++) { for (int j = 0; j < labelAlphabet.size(); j++) { String featName = "TOK_PRED=" + labelAlphabet.lookupObject(j).toString() + "_@_RANK_" + m_predRanks2add[i]; m_dataAlphabet.lookupIndex(featName, true); } } // evaluate token classifier if (testList != null) { Trial trial = new Trial(m_tokenClassifiers, testList); logger.info("Token classifier accuracy on test set = " + trial.getAccuracy()); } }
public AddClassifierTokenPredictions(TokenClassifiers tokenClassifiers, int[] predRanks2add, boolean binary, InstanceList testList) { m_predRanks2add = predRanks2add; m_binary = binary; m_tokenClassifiers = tokenClassifiers; m_inProduction = false; m_dataAlphabet = (Alphabet) tokenClassifiers.getAlphabet().clone(); Alphabet labelAlphabet = tokenClassifiers.getLabelAlphabet(); // add the token prediction features to the alphabet for (int i = 0; i < m_predRanks2add.length; i++) { for (int j = 0; j < labelAlphabet.size(); j++) { String featName = "TOK_PRED=" + labelAlphabet.lookupObject(j).toString() + "_@_RANK_" + m_predRanks2add[i]; m_dataAlphabet.lookupIndex(featName, true); } } // evaluate token classifier if (testList != null) { Trial trial = new Trial(m_tokenClassifiers, testList); logger.info("Token classifier accuracy on test set = " + trial.getAccuracy()); } }
return; Alphabet tmpDV = (Alphabet) ilist.getDataAlphabet().clone(); FeatureSelection featuresSelected = ilist.getFeatureSelection(); InstanceList tmpilist = new InstanceList (tmpDV, ilist.getTargetAlphabet());
return; Alphabet tmpDV = (Alphabet) ilist.getDataAlphabet().clone(); FeatureSelection featuresSelected = ilist.getFeatureSelection(); InstanceList tmpilist = new InstanceList (tmpDV, ilist.getTargetAlphabet());
return; Alphabet tmpDV = (Alphabet) ilist.getDataAlphabet().clone(); FeatureSelection featuresSelected = ilist.getFeatureSelection(); InstanceList tmpilist = new InstanceList (tmpDV, ilist.getTargetAlphabet());