aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/go/util_test.go
diff options
context:
space:
mode:
authorGravatar Asim Shankar <ashankar@google.com>2016-09-28 10:37:31 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-09-28 11:48:45 -0700
commit7cacfdf03872c36cfc3f43e75e8c342234160e3a (patch)
tree0856b1decb0a1f36a68450c9a5d9b825de999c06 /tensorflow/go/util_test.go
parentb410f52f6616e281d8274317938a258605ad993a (diff)
go: Add an example.
Add an example (that will appear in Go doc) for a real use of the Go TensorFlow APIs - using a pre-defined image recognition model for inference. While at it a couple of minor tweaks: - NewSession now accepts 'nil' for options as the documentation says it does - Convenience accessors for the Outputs of an Operation - Ability to extract (possibly partial) shapes from an Output Another step towards #10 Change: 134560938
Diffstat (limited to 'tensorflow/go/util_test.go')
-rw-r--r--tensorflow/go/util_test.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/tensorflow/go/util_test.go b/tensorflow/go/util_test.go
index 2b13df008a..06b4e61d0f 100644
--- a/tensorflow/go/util_test.go
+++ b/tensorflow/go/util_test.go
@@ -18,18 +18,20 @@ func Placeholder(g *Graph, name string, dt DataType) (Output, error) {
b := newOpBuilder(g, "Placeholder", name)
b.SetAttrType("dtype", dt)
op, err := b.Build()
- if err != nil {
- return Output{}, err
- }
- return Output{op, 0}, nil
+ return Output{op, 0}, err
+}
+
+func Const(g *Graph, name string, t *Tensor) (Output, error) {
+ b := newOpBuilder(g, "Const", name)
+ b.SetAttrType("dtype", t.DataType())
+ b.SetAttrTensor("value", t)
+ op, err := b.Build()
+ return Output{op, 0}, err
}
func Neg(g *Graph, name string, port Output) (Output, error) {
b := newOpBuilder(g, "Neg", name)
b.AddInput(port)
op, err := b.Build()
- if err != nil {
- return Output{}, err
- }
- return Output{op, 0}, nil
+ return Output{op, 0}, err
}