From fad91d3eff38410b2ac2709ecbd223d33a7e8371 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Fri, 5 Aug 2016 13:11:30 -0800 Subject: [PATCH] Highlight features of the C++ API in the example. Change: 129480816 --- tensorflow/cc/tutorials/example_trainer.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tensorflow/cc/tutorials/example_trainer.cc b/tensorflow/cc/tutorials/example_trainer.cc index c6351afe302..27ff0914d5f 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 means the result will be a + // float tensor even though the initializer has integers. + auto a = Const(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)