BinaryProblem train = new BinaryProblem(); BinaryProblem test = new BinaryProblem(); if (weight_list != null) { train.weight_list = new ArrayList<Double>(); for (int i = 0; i < size(); i++) { if (i < n_train) { train.input_list.add(input_list.get(i));
/** * A helper function that shuffles the order of the examples in this * problem. * * @param rnd * A random number generator ---- if you use the same random * generator (with the same seed), you will get the same * ordering. */ public void shuffle(Random rnd) { int n_ex = size(); for (int i = 0; i < n_ex; i++) { int j = i + rnd.nextInt(n_ex - i); IInstance tmp_ins = input_list.get(i); input_list.set(i, input_list.get(j)); input_list.set(j, tmp_ins); Integer tmp_st = output_list.get(i); output_list.set(i, output_list.get(j)); output_list.set(j, tmp_st); if (weight_list != null) { Double tmp_weight = weight_list.get(i); weight_list.set(i, weight_list.get(j)); weight_list.set(j, tmp_weight); } } }
for (int i = 0; i < bp.size(); i++) if (bp.output_list.get(i) == 1) alpha_ins_list[i + struct_size] = new L2LossPositiveInstanceWithAlphas( C_binary); } else { for (int i = 0; i < bp.size(); i++) { if (bp.output_list.get(i) == 1) alpha_ins_list[i + struct_size] = new L2LossPositiveInstanceWithAlphas(
int bp_size = size(); for (int i = 0; i < bp_size; i++) index_list.add(i); BinaryProblem cv_train = new BinaryProblem(); BinaryProblem cv_test = new BinaryProblem();
protected WeightVector multiThreadGetJointWeightVector(WeightVector old_wv, final AbstractStructureFinder[] struct_finder_list, StructuredProblem sp, BinaryProblem bp, JLISParameters para) throws Exception { int struct_size = sp.size(); int binary_size = bp.size(); int total_size = struct_size + binary_size; System.out.println("Number of traing data: #struct: " + struct_size + " #binary: " + binary_size); WeightVector new_wv = new WeightVector(old_wv, 0); // allocate bias term // for indirect // supervision L2LossInstanceWithAlphas[] alpha_ins_list = initArrayOfInstances(sp, bp, para.c_struct, para.c_binary, struct_size, total_size); return multitreadTrainJLIS(struct_finder_list, para.MAX_OUT_ITER, struct_size, total_size, new_wv, alpha_ins_list, para) .getFirst(); }
L2LossInstanceWithAlphas.setJLISParameters(para); int struct_size = sp.size(); int binary_size = bp.size();
int binary_size = empty_b.size(); int total_size = struct_size + binary_size;