MCPcopy Create free account
hub / github.com/brightmart/text_classification / get_label_using_logits

Function get_label_using_logits

a08_EntityNetwork/a3_train.py:199–207  ·  view source on GitHub ↗
(logits,vocabulary_index2word_label,top_number=1)

Source from the content-addressed store, hash-verified

197
198#从logits中取出前五 get label using logits
199def get_label_using_logits(logits,vocabulary_index2word_label,top_number=1):
200 #print("get_label_using_logits.logits:",logits) #1-d array: array([-5.69036102, -8.54903221, -5.63954401, ..., -5.83969498,-5.84496021, -6.13911009], dtype=float32))
201 index_list=np.argsort(logits)[-top_number:]
202 index_list=index_list[::-1]
203 #label_list=[]
204 #for index in index_list:
205 # label=vocabulary_index2word_label[index]
206 # label_list.append(label) #('get_label_using_logits.label_list:', [u'-3423450385060590478', u'2838091149470021485', u'-3174907002942471215', u'-1812694399780494968', u'6815248286057533876'])
207 return index_list
208
209#统计预测的准确率
210def calculate_accuracy(labels_predicted, labels,eval_counter):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected