|
@@ -107,28 +107,33 @@ public class TensorflowModel {
|
|
|
FloatBuffer.wrap(inputValues)
|
|
|
);
|
|
|
|
|
|
- float[][] result = null;
|
|
|
+ inputTensor.close();
|
|
|
|
|
|
- // 序列数据
|
|
|
- if (this.withSequenceInputs){
|
|
|
- Map<String, Tensor<Integer>> sequenceTensorMap = this.wrapSequenceInputs(sequenceValues, numExamples);
|
|
|
- this.session.runner();
|
|
|
-
|
|
|
- result = this.session.runner().feed(this.X, inputTensor)
|
|
|
- .feed(this.Char_ids, sequenceTensorMap.get(this.Char_ids))
|
|
|
- .feed(this.Pos_ids, sequenceTensorMap.get(this.Pos_ids))
|
|
|
- .feed("keep_prob", Tensor.create(1.0f, Float.class)) // dropout保留率
|
|
|
- .fetch(this.SOFT_MAX).run().get(0)
|
|
|
- .copyTo(new float[numExamples][this.NUM_LABEL]);
|
|
|
- }else{
|
|
|
- result = this.session.runner().feed(this.X, inputTensor)
|
|
|
- .feed("keep_prob", Tensor.create(1.0f, Float.class)) // dropout保留率
|
|
|
- .fetch(this.SOFT_MAX).run().get(0)
|
|
|
- .copyTo(new float[numExamples][this.NUM_LABEL]);
|
|
|
+ float[][] fl = new float[numExamples][NUM_LABEL];
|
|
|
+ for (int i = 0; i < numExamples; i++) {
|
|
|
+ for (int j = 0; j < NUM_LABEL; j++) {
|
|
|
+ fl[i][j] = 0.1f;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- inputTensor.close();
|
|
|
- return result;
|
|
|
+ return fl;
|
|
|
+//
|
|
|
+// // 序列数据
|
|
|
+// if (this.withSequenceInputs){
|
|
|
+// Map<String, Tensor<Integer>> sequenceTensorMap = this.wrapSequenceInputs(sequenceValues, numExamples);
|
|
|
+// this.session.runner();
|
|
|
+//
|
|
|
+// return this.session.runner().feed(this.X, inputTensor)
|
|
|
+// .feed(this.Char_ids, sequenceTensorMap.get(this.Char_ids))
|
|
|
+// .feed(this.Pos_ids, sequenceTensorMap.get(this.Pos_ids))
|
|
|
+// .feed("keep_prob", Tensor.create(1.0f, Float.class)) // dropout保留率
|
|
|
+// .fetch(this.SOFT_MAX).run().get(0)
|
|
|
+// .copyTo(new float[numExamples][this.NUM_LABEL]);
|
|
|
+// }else{
|
|
|
+// return this.session.runner().feed(this.X, inputTensor)
|
|
|
+// .feed("keep_prob", Tensor.create(1.0f, Float.class)) // dropout保留率
|
|
|
+// .fetch(this.SOFT_MAX).run().get(0)
|
|
|
+// .copyTo(new float[numExamples][this.NUM_LABEL]);
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
|