Explorar el Código

1- 添加关系抽取基本模型。

bijl hace 6 años
padre
commit
3c7e591a67

+ 32 - 0
algorithm/src/main/java/org/algorithm/core/cnn/model/RelationExtractionModel.java

@@ -0,0 +1,32 @@
+package org.algorithm.core.cnn.model;
+
+import org.tensorflow.SavedModelBundle;
+import org.tensorflow.Session;
+
+/**
+ * @Author: bijl
+ * @Date: 2019/1/22 10:21
+ * @Decription:
+ */
+public class RelationExtractionModel {
+    private final String xx = null;
+    private SavedModelBundle bundle; // 模型捆绑
+    private Session session;  // 会话
+
+    /**
+     * 初始化:加载模型,获取会话。
+     * @param exportDir
+     */
+    public void init(String exportDir) {
+        /* load the model Bundle */
+        try {
+            this.bundle = SavedModelBundle.load(exportDir, "serve");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        // create the session from the Bundle
+        this.session = bundle.session();
+    }
+
+}