Skip to content

Commit fcdbc36

Browse files
authored
[samples/java]: Explain where tensor names came from.
Fixes tensorflow/tensorflow#19348
1 parent 493d7a2 commit fcdbc36

File tree

1 file changed

+9
-2
lines changed
  • samples/languages/java/training/src/main/java

1 file changed

+9
-2
lines changed

samples/languages/java/training/src/main/java/Train.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ public static void main(String[] args) throws Exception {
4242
Tensors.create(Paths.get(checkpointDir, "ckpt").toString())) {
4343
graph.importGraphDef(graphDef);
4444

45-
// Initialize or restore
45+
// Initialize or restore.
46+
// The names of the tensors in the graph are printed out by the program
47+
// that created the graph:
48+
// https://github.com/tensorflow/models/blob/master/samples/languages/java/training/model/create_graph.py
4649
if (checkpointExists) {
4750
sess.runner().feed("save/Const", checkpointPrefix).addTarget("save/restore_all").run();
4851
} else {
@@ -60,14 +63,18 @@ public static void main(String[] args) throws Exception {
6063
float in = r.nextFloat();
6164
try (Tensor<Float> input = Tensors.create(in);
6265
Tensor<Float> target = Tensors.create(3 * in + 2)) {
66+
// Again the tensor names are from the program that created the graph.
67+
// https://github.com/tensorflow/models/blob/master/samples/languages/java/training/model/create_graph.py
6368
sess.runner().feed("input", input).feed("target", target).addTarget("train").run();
6469
}
6570
}
6671
System.out.printf("After %5d examples: ", i*NUM_EXAMPLES);
6772
printVariables(sess);
6873
}
6974

70-
// Checkpoint
75+
// Checkpoint.
76+
// The feed and target name are from the program that created the graph.
77+
// https://github.com/tensorflow/models/blob/master/samples/languages/java/training/model/create_graph.py.
7178
sess.runner().feed("save/Const", checkpointPrefix).addTarget("save/control_dependency").run();
7279

7380
// Example of "inference" in the same graph:

0 commit comments

Comments
 (0)