| @@ -68,8 +68,8 @@ class AbducerBase(abc.ABC): | |||||
| if len(candidates) > 0: | if len(candidates) > 0: | ||||
| score += np.min(self._get_cost_list(pred_res[idx], pred_res_prob[idx], candidates)) | score += np.min(self._get_cost_list(pred_res[idx], pred_res_prob[idx], candidates)) | ||||
| else: | else: | ||||
| score += len(pred_res) | |||||
| return -self._zoopt_score_multiple(pred_res, key, sol.get_x()) | |||||
| score += len(pred_res[idx]) | |||||
| return score | |||||
| def _constrain_address_num(self, solution, max_address_num): | def _constrain_address_num(self, solution, max_address_num): | ||||
| x = solution.get_x() | x = solution.get_x() | ||||
| @@ -291,7 +291,7 @@ def train_with_rule(model, abducer, train_data, val_data, select_num=10, min_len | |||||
| INFO('consist_rule_acc is %f, %f\n' %(true_consist_rule_acc, false_consist_rule_acc)) | INFO('consist_rule_acc is %f, %f\n' %(true_consist_rule_acc, false_consist_rule_acc)) | ||||
| # decide next course or restart | # decide next course or restart | ||||
| if true_consist_rule_acc > 0.9 and false_consist_rule_acc < 0.1: | |||||
| if true_consist_rule_acc > 0.95 and false_consist_rule_acc < 0.1: | |||||
| torch.save(model.cls_list[0].model.state_dict(), "./weights/weights_%d.pth" % equation_len) | torch.save(model.cls_list[0].model.state_dict(), "./weights/weights_%d.pth" % equation_len) | ||||
| break | break | ||||
| else: | else: | ||||
| @@ -19,7 +19,8 @@ def reform_idx(flatten_pred_res, save_pred_res): | |||||
| return re | return re | ||||
| def hamming_dist(A, B): | def hamming_dist(A, B): | ||||
| B = np.array(B) | |||||
| A = np.array(A, dtype='<U') | |||||
| B = np.array(B, dtype='<U') | |||||
| A = np.expand_dims(A, axis = 0).repeat(axis=0, repeats=(len(B))) | A = np.expand_dims(A, axis = 0).repeat(axis=0, repeats=(len(B))) | ||||
| return np.sum(A != B, axis = 1) | return np.sum(A != B, axis = 1) | ||||