Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

jiangnanboy/java_textcnn_onnx

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java_textcnn_onnx

java is used to load the onnx format model of textcnn

step

1.after training the textcnn model, convert it to onnx format (src/main/resource/model.onnx)

2.extract token mapping dict (src/main/resources/token.txt)

3.use java to load onnx format model and token dict (src/main/java/Init)

4.inference and prediction (src/main/java/Inference)

example

(text binary classification)

predict:src/main/java/Inference

public static void main(String...args) throws OrtException {
        Map<String, OnnxTensor> inputMap = parse("我们热爱人工智能。");
        System.out.println(Init.session.getInputInfo());
        System.out.println(Init.session.getOutputInfo());
        double prob = infer(inputMap);
        System.out.println("prob -> " + prob);
    }

contact

1、github:https://github.com/jiangnanboy

2、blog:https://www.cnblogs.com/little-horse/

3、e-mail:2229029156@qq.com

About

java is used to load the onnx format model of textcnn

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.