Code Monkey home page Code Monkey logo

Comments (7)

nomel0921 avatar nomel0921 commented on May 18, 2024 2

训练结束后predict.py脚本获取不到标签问题 知乎上也有很多人说predict.py脚本获取到的标签为空,其实不是训练数据有问题或者轮次不够,作者的get_label 函数逻辑有一些小小的问题,我这里简单修改了一下,可以成功获取到标签,新的predict.py 的get_label 函数如下:

def get_label(sentence):
    """
    Prediction of the sentence's label.
    """
    feature = get_feature_test(sentence)
    fd = {MODEL.albert.input_ids: [feature[0]],
          MODEL.albert.input_masks: [feature[1]],
          MODEL.albert.segment_ids:[feature[2]],
          }
    prediction = MODEL.sess.run(MODEL.albert.predictions, feed_dict=fd)[0]
    print(prediction)
    r=[]
    for i in range(len(prediction)):
        if prediction[i]!=0.0:
            r.append(id2label(i))
    return r
    #return [id2label(l) for l in np.where(prediction==1)[0] if l!=0]

您好,按照您的修改之后我的输出都是第一个标签了...我看了下任何句子的prediction几乎相等,这是什么原因呢...

from classifier-multi-label.

hellonlp avatar hellonlp commented on May 18, 2024

建议打印prediction看看

from classifier-multi-label.

lonkecxd avatar lonkecxd commented on May 18, 2024

请问你这个问题解决了吗?我也遇到了,prediction结果都是[]。

from classifier-multi-label.

hellonlp avatar hellonlp commented on May 18, 2024

我的第一个标签是空标签"|",所以会不一样

from classifier-multi-label.

xtuyaowu avatar xtuyaowu commented on May 18, 2024

大家有用起来么?要不要加个QQ好友交流一下?qq:1840658279

from classifier-multi-label.

rio5050 avatar rio5050 commented on May 18, 2024

prediction打印出来全是0......

from classifier-multi-label.

hellonlp avatar hellonlp commented on May 18, 2024

是正常的,说明预测结果为空

from classifier-multi-label.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.