diff options
author | 2016-09-23 10:25:02 -0800 | |
---|---|---|
committer | 2016-09-23 11:33:41 -0700 | |
commit | 7bffed6ba12a4d463a0dfb1978e2108343c63eaf (patch) | |
tree | 292e668023177bb637d1fae08f1905b843f3a32e /tensorflow/go/util_test.go | |
parent | f982313d3c32cf2c7018eae9ec49759ae111d407 (diff) |
go: Ability to import a pre-defined Graph.
With this change, it should be possible to execute
a pre-defined Graph created by any means (like a
training session in a Python program) in Go.
One more step towards #10
Change: 134096795
Diffstat (limited to 'tensorflow/go/util_test.go')
-rw-r--r-- | tensorflow/go/util_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tensorflow/go/util_test.go b/tensorflow/go/util_test.go new file mode 100644 index 0000000000..2b13df008a --- /dev/null +++ b/tensorflow/go/util_test.go @@ -0,0 +1,35 @@ +// Copyright 2016 The TensorFlow Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package tensorflow + +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 +} + +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 +} |