|
@@ -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();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|