INNER CODE UNIT · Python
total_batch
ShannonAI/glyce · glyce/models/latticeLSTM/main.py:175
total_batch = train_num//data.HP_batch_size+1
for batch_id in range(total_batch):
start = batch_id*data.HP_batch_size
end = (batch_id+1)*data.HP_batch_size
if end > train_num:
end = train_num
instance = instances[start:end]
if not instance:
continue
gaz_list, batch_word, batch_biword, batch_wordlen, batch_wordrecover, batch_char, batch_charlen, batch_charrecover, batch_label, mask = batchify_with_label(instance, data.HP_gpu, True)
tag_seq = model(gaz_list,batch_word, batch_biword, batch_wordlen, batch_char, batch_charlen, batch_charrecover, mask)
# logger.info("tag_seq", tag_seq)
pred_label, gold_label = recover_label(tag_seq, batch_label, mask, data.label_alphabet, batch_wordrecover)
pred_results += pred_label
gold_results += gold_label
decode_time = time.time() - start_time
speed = len(instances)/decode_time