Git Product home page Git Product logo

2021ccf-iqiyi's Introduction

CCF BDCI 剧本角色情感识别

#将baseline程序is_train改成True就是启动训练,此版本训练是多gpu的,如果但gpu训练可以稍微改下

python baseline就能启动训练

#模型预测就是is_train改成False然后把gpu指定改成单卡就可以进行推理了。

python baseline能启动推理

自动调用model_predict函数生成result.tsv文件,支持修改推理不同的文件。

2021ccf-iqiyi's People

Contributors

core-power avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

2021ccf-iqiyi's Issues

baseline问题~

def build_model():
    token_ids = Input(shape=(None,))  
    segment_ids = Input(shape=(None,))

    bert = build_transformer_model(
        config_path=config_path,
        checkpoint_path=checkpoint_path,
        model='bert',
        return_keras_model=False
    )

    output = Lambda(lambda x: x[:, 0])(bert.model([token_ids, segment_ids]))  # 取出output中的第一个值,代表[cls]的值

    output_love = Dense(units=emotion_classes,activation='softmax',kernel_initializer=bert.initializer,name='love_classes')(output)  # (?,4)
    output_happy = Dense(units=emotion_classes,activation='softmax',kernel_initializer=bert.initializer,name='happy_classes')(output)  # (?,4)
    output_scare = Dense(units=emotion_classes,activation='softmax',kernel_initializer=bert.initializer,name='scare_classes')(output)  # (?,4)
    output_angry = Dense(units=emotion_classes,activation='softmax',kernel_initializer=bert.initializer,name='angry_classes')(output)  # (?,4)
    output_afraid = Dense(units=emotion_classes,activation='softmax',kernel_initializer=bert.initializer,name='afraid_classes')(output)  # (?,4)
    output_sad = Dense(units=emotion_classes,activation='softmax',kernel_initializer=bert.initializer,name='sad_classes')(output)  # (?,4)


    model = keras.models.Model([token_ids, segment_ids], [output_love, output_happy,output_scare,output_angry,output_afraid,output_sad])
    model.summary()

    model.compile(
        loss='categorical_crossentropy',
        optimizer=Adam(lr),
        metrics=['categorical_accuracy']
    )
    return model

代码如上,使用的也是苏神的bert4keras。想实现简单的多标签分类baseline,模型共享一个bert和输入,然后构造6个输出,但是很奇怪:①模型输出的是全0;②6个输出的值一模一样。请问是哪里出问题了呢?万分感谢!

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.