@Override public void run() { int index = 0; for (L2LossInstanceWithAlphas ins : alpha_ins_list) { // focus on positive know if (!ins.isBinary() || ins.getY() == -1) continue; double score = 0; try { score = ins.updateRepresentationCollection(wv, s_finder); } catch (Exception e) { e.printStackTrace(); System.exit(1); } if (score > L2LossInstanceWithAlphas.BINARY_DUAL_GAP) { n_b_new += 1; } // System.out.println("now: " + index); index++; } if (verbose_level >= JLISParameters.VLEVEL_HIGH) { System.out.println("Thread: (b) udpate = " + n_b_new); } } }
protected void updateStructuresForBinaryPositiveExamples( WeightVector new_wv, L2LossInstanceWithAlphas[] alpha_ins_list, AbstractStructureFinder struct_finder) throws Exception { // update positive examples int n_p = 0; int n_p_changed = 0; int total_size = alpha_ins_list.length; for (int i = 0; i < total_size; i++) { L2LossInstanceWithAlphas p_ins = alpha_ins_list[i]; if (i % verbose_step == 0) System.out.println("positive_xi inference stage: " + i + "/" + total_size); if (p_ins.isBinary() && p_ins.getY() == 1) { n_p += 1; double updated = p_ins.updateRepresentationCollection(new_wv, struct_finder); if (updated > 0) n_p_changed += 1; } } System.out.println("Among " + n_p + " examples, " + n_p_changed + "updated "); }
assert ins.isBinary() == false; L2LossStructureInstanceWithAlphas sins = (L2LossStructureInstanceWithAlphas) ins; IStructure pre_gold = sins.gold_struct;
private Pair<Integer, Integer> updateStructuresforNegativeAndStructuredExamples( L2LossInstanceWithAlphas[] alpha_ins_list, WeightVector new_wv, int struct_size, AbstractStructureFinder struct_finder) throws Exception { int n_s_new = 0; int n_b_new = 0; int total_size = alpha_ins_list.length; for (int i = 0; i < total_size; i++) { // positive h has already been fixed if (alpha_ins_list[i].isBinary() && alpha_ins_list[i].getY() == 1) continue; double score = alpha_ins_list[i].updateRepresentationCollection( new_wv, struct_finder); if (i < struct_size) { if (score > L2LossInstanceWithAlphas.DUAL_GAP) { n_s_new += 1; } } else { if (score > L2LossInstanceWithAlphas.BINARY_DUAL_GAP) { n_b_new += 1; } } } return new Pair<Integer, Integer>(n_s_new, n_b_new); }
if (alpha_ins_list[i].isBinary() && alpha_ins_list[i].getY() == 1) n_postive++;