示例#1
0
def evaluate_scws(sess, en_dh, batch_size, en_ss, en_srl):
    global global_maxSimC
    global global_avgSimC

    [senseVec, senseScore] = getEmbedding(sess,
                                          en_dh,
                                          batch_size,
                                          en_ss,
                                          en_srl.embedded_sense_input,
                                          en_srl.selected_sense_input_indices,
                                          scws=True)

    indices1 = range(0, len(senseVec), 2)
    indices2 = range(1, len(senseVec), 2)

    avgSimC = calAvgSimC(en_dh.scws_test_score, senseVec[indices1],
                         senseScore[indices1], senseVec[indices2],
                         senseScore[indices2])
    maxSimC = calMaxSimC(en_dh.scws_test_score, senseVec[indices1],
                         senseScore[indices1], senseVec[indices2],
                         senseScore[indices2])

    scores = [maxSimC, avgSimC]
    score_name = ['MaxSimC', 'AvgSimC']
    print 'scws AvgSimC =', '{:.5f}'.format(
        avgSimC), 'MaxSimC =', '{:.5f}'.format(maxSimC)
    ret_str = 'scws AvgSimC = {:.5f}'.format(
        avgSimC) + ' MaxSimC = {:.5f}'.format(maxSimC)
    return ret_str, scores, score_name
示例#2
0
文件: main.py 项目: qianchu/CLUSE
def evaluate_scws(sess, en_dh, batch_size, en_ss, en_srl):
    global global_maxSimC
    global global_avgSimC

    [senseVec, senseScore] = getEmbedding(sess,
                                          en_dh,
                                          batch_size,
                                          en_ss,
                                          en_srl.embedded_sense_input,
                                          en_srl.selected_sense_input_indices,
                                          scws=True)

    indices1 = range(0, len(senseVec), 2)
    indices2 = range(1, len(senseVec), 2)

    avgSimC = calAvgSimC(en_dh.scws_test_score, senseVec[indices1],
                         senseScore[indices1], senseVec[indices2],
                         senseScore[indices2])
    maxSimC = calMaxSimC(en_dh.scws_test_score, senseVec[indices1],
                         senseScore[indices1], senseVec[indices2],
                         senseScore[indices2])

    scores = [maxSimC, avgSimC]
    if maxSimC > ckpt_threshold and maxSimC > global_maxSimC:
        global_maxSimC = maxSimC
        eval_save_model(sess, '-bestMaxC-')
    if avgSimC > ckpt_threshold and avgSimC > global_avgSimC:
        global_avgSimC = avgSimC
        eval_save_model(sess, '-bestAvgC-')
    print 'scws AvgSimC =', '{:.5f}'.format(
        avgSimC), 'MaxSimC =', '{:.5f}'.format(maxSimC)
    ret_str = 'scws AvgSimC = {:.5f}'.format(
        avgSimC) + ' MaxSimC = {:.5f}'.format(maxSimC)
    return ret_str
示例#3
0
文件: main.py 项目: qianchu/CLUSE
def evaluate_bcws(sess, en_dh, ch_dh, batch_size, en_ss, ch_ss, en_opt,
                  ch_opt):
    global global_bmaxSimC
    global global_bavgSimC

    [en_senseVec, en_senseScore] = getEmbedding(sess, en_dh, batch_size, en_ss,
                                                *bcws_dict[en_opt])
    [ch_senseVec, ch_senseScore] = getEmbedding(sess, ch_dh, batch_size, ch_ss,
                                                *bcws_dict[ch_opt])

    assert en_dh.test_score == ch_dh.test_score
    avgSimC = calAvgSimC(en_dh.test_score, en_senseVec, en_senseScore,
                         ch_senseVec, ch_senseScore)
    maxSimC = calMaxSimC(en_dh.test_score, en_senseVec, en_senseScore,
                         ch_senseVec, ch_senseScore)

    if maxSimC > bckpt_threshold and maxSimC > global_bmaxSimC:
        global_bmaxSimC = maxSimC
        eval_save_model(sess, '-bestbMaxC_{}_{}-'.format(en_opt, ch_opt))
    if avgSimC > bckpt_threshold and avgSimC > global_bavgSimC:
        global_bavgSimC = avgSimC
        eval_save_model(sess, '-bestbAvgC_{}_{}-'.format(en_opt, ch_opt))
    ret_str = 'bcws {} {} AvgSimC = '.format(en_opt, ch_opt) + '{:.5f}'.format(
        avgSimC) + ' MaxSimC = ' + '{:.5f}'.format(maxSimC)
    print(ret_str)
    return ret_str
示例#4
0
def evaluate_bcws(sess, en_dh, ch_dh, batch_size, en_ss, ch_ss, en_srl, ch_srl):
    global global_bmaxSimC
    global global_bavgSimC
    
    [en_senseVec, en_senseScore] = getEmbedding(sess, en_dh, batch_size, en_ss, en_srl.embedded_sense_input, en_srl.selected_sense_input_indices)
    [ch_senseVec, ch_senseScore] = getEmbedding(sess, ch_dh, batch_size, ch_ss, ch_srl.embedded_sense_input, ch_srl.selected_sense_input_indices)
    
    assert en_dh.test_score == ch_dh.test_score
    avgSimC = calAvgSimC(en_dh.test_score, en_senseVec, en_senseScore, ch_senseVec, ch_senseScore)
    maxSimC = calMaxSimC(en_dh.test_score, en_senseVec, en_senseScore, ch_senseVec, ch_senseScore)

    print ('bcws AvgSimC =','{:.5f}'.format(avgSimC), 'MaxSimC =','{:.5f}'.format(maxSimC))
示例#5
0
def evaluate(sess):
  with Timer("get embedding for 1st half of evaluation data"):
    [senseVec, senseScore] = getEmbedding(sess,testData, testLocation)

  indices1 = range(0,len(senseVec),2)
  indices2 = range(1,len(senseVec),2)

  avgSimC = calAvgSimC(test_score, senseVec[indices1], senseScore[indices1], senseVec[indices2], senseScore[indices2])
  maxSimC = calMaxSimC(test_score, senseVec[indices1], senseScore[indices1], senseVec[indices2], senseScore[indices2])
  
  scores = [maxSimC, avgSimC]
  score_name = ['MaxSimC', 'AvgSimC']
  
  print 'AvgSimC =','{:.5f}'.format(avgSimC), 'MaxSimC =','{:.5f}'.format(maxSimC)
  return [scores, score_name]