def __init__(self, packer, l_map, SCRF_l_map):

        self.packer = packer
        self.l_map = l_map
        self.SCRF_l_map = SCRF_l_map
        self.r_l_map = utils.revlut(l_map)
        self.SCRF_r_l_map = utils.revlut(SCRF_l_map)
Exemple #2
0
    def __init__(self, c_map, l_map, seg_l_map, ent_l_map, w_map, win_size, gpu=0):
        self.l_map = l_map
        self.seg_l_map = seg_l_map
        self.ent_l_map = ent_l_map

        self.w_map = w_map
        self.c_map = c_map
        self.r_w_map = utils.revlut(w_map)
        self.r_l_map = utils.revlut(l_map)
        self.gpu = gpu
        self.win_size = win_size
Exemple #3
0
    def __init__(self, packer, c_map, l_map, removed_label):

        self.removed_label = removed_label
        self.packer = packer
        self.l_map = l_map
        self.r_l_map = utils.revlut(l_map)
        self.c_map = c_map
        self.r_c_map = utils.revlut(c_map)
        self.totalp_counts = {}
        self.truep_counts = {}
        self.fn_counts = {}
        self.fp_counts = {}
        self.f1 = {}
 def __init__(self, packer, l_map):
     self.packer = packer
     self.l_map = l_map
     self.r_l_map = utils.revlut(l_map)
     self.totalp_counts={}
     self.truep_counts={}
     self.fn_counts={}
     self.fp_counts={}
     self.f1={}
 def __init__(self, packer, l_map):
     self.packer = packer
     self.l_map = l_map
     self.r_l_map = utils.revlut(l_map)
Exemple #6
0
    best_f1 = float('-inf')
    best_acc = float('-inf')
    track_list = list()
    start_time = time.time()
    epoch_list = range(args.start_epoch, args.start_epoch + args.epoch)
    patience_count = 0

    evaluator = eval_wc(packer, c_map, l_map)
    evaluator_filter = eval_wc(packer, c_map, l_map, ['B-site', 'I-site', 'O'])
    print("start training...")
    loss_list=[]
    crf_loss_list=[]
    lm_loss_list=[]

    f1_test_list=[]
    r_c_map = utils.revlut(c_map)
    for epoch_idx, args.start_epoch in enumerate(epoch_list):

        epoch_loss = 0
        crf_loss=0
        lm_loss=0
        ner_model.train()
        args.lambda0=max(1-args.lambda0_dr*args.start_epoch,args.lambda0_min_value)
        data={"train":dataset_loader,"co":co_dataset_loader}
        for i in data:
          
          for f_f, f_p, b_f, b_p, w_f, tg_v, mask_v, len_v in tqdm(
                itertools.chain.from_iterable(data[i]), mininterval=2,
                desc=' - Tot it %d (epoch %d)' % (tot_length, args.start_epoch), leave=False, file=sys.stdout):
            mask_v=mask_v.bool()
            f_f, f_p, b_f, b_p, w_f, tg_v, mask_v = packer.repack_vb(f_f, f_p, b_f, b_p, w_f, tg_v, mask_v, len_v)