Code Monkey home page Code Monkey logo

bert-text-classification-j's Introduction

Ensemble Classification Demo

Implemented TextCNNs,BERT as well as the weighted vote ensemble method.

This repository contains the whole inference process of both BERT and TextCNNs, including preprocessing and prediction.

Preparation

  1. Firstly, you must have exported either BERT/TextCNNs models into .pb format. For BERT models, you can find the solution to exporting BERT .pb model by checking https://github.com/cyk1337/BERT-Classification/blob/master/bert/run_classification.py.
  2. Then, use the .pb model path to initialize the model class at
    String bert_model_path = "pb_model/bert_L4_FC3_Seq128.pb";
    , suppose you have generated .pb model correctly.

bert-text-classification-j's People

Contributors

cyk1337 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bert-text-classification-j's Issues

I got NullPointerException after load bert model

my Exception:

Starting to predict!
====================== Start loading models ... ======================
====================== Models loaded! ======================
java.lang.NullPointerException
at com.google.common.io.ByteStreams.copy(ByteStreams.java:167)
at com.google.common.io.ByteStreams.toByteArray(ByteStreams.java:210)
at model.BaseModel.(BaseModel.java:21)
at model.Bert.(Bert.java:10)
at EnsembleDemo._load_Bert(EnsembleDemo.java:56)
at EnsembleDemo.loadModels(EnsembleDemo.java:50)
at EnsembleDemo.(EnsembleDemo.java:21)
at EnsembleDemo.main(EnsembleDemo.java:164)
Exception in thread "main" java.lang.NullPointerException
at model.Bert.predict_single_case(Bert.java:21)
at EnsembleDemo.__pred_with_Bert(EnsembleDemo.java:79)
at EnsembleDemo.doPredictWithModels(EnsembleDemo.java:63)
at EnsembleDemo.main(EnsembleDemo.java:174)

Is this Exception because of the pb file?
how to generate the pb file correctly? i generate it through the code:

frozen_graph = convert_variables_to_constants(sess, input_graph_def, output_names)

i don't know how auther generate it.
and or other problem cause the Exception.

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.