aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/cc/tutorials
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2016-08-05 13:11:30 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-08-05 14:18:06 -0700
commitfad91d3eff38410b2ac2709ecbd223d33a7e8371 (patch)
tree4c45c6ae6725feb3cf11fbddf85842837397cef0 /tensorflow/cc/tutorials
parent576ff3bf9b28eb9411d2c6bdf216224cfda56c66 (diff)
Highlight features of the C++ API in the example.
Change: 129480816
Diffstat (limited to 'tensorflow/cc/tutorials')
-rw-r--r--tensorflow/cc/tutorials/example_trainer.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/tensorflow/cc/tutorials/example_trainer.cc b/tensorflow/cc/tutorials/example_trainer.cc
index c6351afe30..27ff0914d5 100644
--- a/tensorflow/cc/tutorials/example_trainer.cc
+++ b/tensorflow/cc/tutorials/example_trainer.cc
@@ -52,19 +52,22 @@ GraphDef CreateGraphDef() {
Scope root = Scope::NewRootScope();
using namespace ::tensorflow::ops; // NOLINT(build/namespaces)
- // a = [3 2; -1 0]
- auto a = Const(root, {{3.f, 2.f}, {-1.f, 0.f}});
+ // A = [3 2; -1 0]. Using Const<float> means the result will be a
+ // float tensor even though the initializer has integers.
+ auto a = Const<float>(root, {{3, 2}, {-1, 0}});
// x = [1.0; 1.0]
auto x = Const(root.WithOpName("x"), {{1.f}, {1.f}});
- // y = a * x
+ // y = A * x
auto y = MatMul(root.WithOpName("y"), a, x);
// y2 = y.^2
auto y2 = Square(root, y);
- // y2_sum = sum(y2)
+ // y2_sum = sum(y2). Note that you can pass constants directly as
+ // inputs. Sum() will automatically create a Const node to hold the
+ // 0 value.
auto y2_sum = Sum(root, y2, 0);
// y_norm = sqrt(y2_sum)