@@ -95,77 +95,6 @@ public void loader() {
95
95
}
96
96
}
97
97
98
- // @Test
99
- // public void exportFunctionWithVariables() throws IOException {
100
- // Path testFolder = Files.createTempDirectory("tf-saved-model-export-test");
101
- // float reducedSum;
102
- // FloatNdArray xValue = StdArrays.ndCopyOf(new float[][]{{0, 1, 2}, {3, 4, 5}});
103
- // Shape xyShape = Shape.of(2, 3L);
104
- // try (ConcreteFunction f = ConcreteFunction.create(tf -> buildGraphWithVariables(tf, xyShape))) {
105
- // // Init variable state by running the Init operation directly
106
- // //TODO f.session().run(Init.DEFAULT_NAME);
107
- //
108
- // // Call the graph and remember the result of computation for later
109
- // try (TFloat32 xTensor = TFloat32.tensorOf(xValue);
110
- // TFloat32 zTensor = (TFloat32)f.call(xTensor)) {
111
- // reducedSum = zTensor.getFloat();
112
- // }
113
- // // Save/export the model (which is a single function in this case)
114
- // f.save(testFolder.toString());
115
- // }
116
- // assertTrue(Files.exists(testFolder.resolve(Paths.get("variables", "variables.index"))));
117
- // assertTrue(Files
118
- // .exists(testFolder.resolve(Paths.get("variables", "variables.data-00000-of-00001"))));
119
- // assertTrue(Files.exists(testFolder.resolve("saved_model.pb")));
120
- //
121
- // // Reload the model just saved and validate its data
122
- // try (SavedModelBundle savedModel =
123
- // SavedModelBundle.load(testFolder.toString(), SavedModelBundle.DEFAULT_TAG)) {
124
- // assertNotNull(savedModel.metaGraphDef());
125
- // assertNotNull(savedModel.metaGraphDef().getSaverDef());
126
- // assertEquals(1, savedModel.metaGraphDef().getSignatureDefCount());
127
- // assertEquals(Signature.DEFAULT_KEY,
128
- // savedModel.metaGraphDef().getSignatureDefMap().keySet().iterator().next());
129
- //
130
- // SessionFunction function = savedModel.function(Signature.DEFAULT_KEY);
131
- // assertNotNull(function);
132
- //
133
- // Signature signature = function.signature();
134
- // assertNotNull(signature);
135
- // assertEquals(1, signature.inputNames().size());
136
- // assertEquals("input", signature.inputNames().iterator().next());
137
- // assertEquals(1, signature.outputNames().size());
138
- // assertEquals("reducedSum", signature.outputNames().iterator().next());
139
- //
140
- // SignatureDef signatureDef = signature.asSignatureDef();
141
- // assertEquals(1, signatureDef.getInputsCount());
142
- // assertEquals(1, signatureDef.getOutputsCount());
143
- //
144
- // TensorInfo inputInfo = signatureDef.getInputsMap().get("input");
145
- // assertNotNull(inputInfo);
146
- // assertEquals(xyShape.numDimensions(), inputInfo.getTensorShape().getDimCount());
147
- // for (int i = 0; i < xyShape.numDimensions(); ++i) {
148
- // assertEquals(xyShape.size(i), inputInfo.getTensorShape().getDim(i).getSize());
149
- // }
150
- //
151
- // TensorInfo outputInfo = signatureDef.getOutputsMap().get("reducedSum");
152
- // assertNotNull(outputInfo);
153
- // assertEquals(0, outputInfo.getTensorShape().getDimCount());
154
- //
155
- // try (TFloat32 xTensor = TFloat32.tensorOf(xValue)) {
156
- // // Call the saved model function and make sure it returns the same result as before
157
- // try (TFloat32 zTensor = (TFloat32)function.call(xTensor)) {
158
- // assertEquals(reducedSum, zTensor.getFloat(), EPSILON);
159
- // }
160
- // // Now call the same function directly from the model
161
- // try (TFloat32 zTensor =
162
- // (TFloat32)savedModel.call(Collections.singletonMap("input", xTensor)).get("reducedSum")) {
163
- // assertEquals(reducedSum, zTensor.getFloat(), EPSILON);
164
- // }
165
- // }
166
- // }
167
- // }
168
-
169
98
@ Test
170
99
public void exportMultipleFunctions () throws IOException {
171
100
Path testFolder = Files .createTempDirectory ("tf-saved-model-export-test" );
0 commit comments