op

package
v2.17.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2024 License: Apache-2.0, BSD-2-Clause Imports: 3 Imported by: 151

Documentation ¶

Overview ¶

Package op defines functions for adding TensorFlow operations to a Graph.

Functions for adding an operation to a graph take a Scope object as the first argument. The Scope object encapsulates a graph and a set of properties (such as a name prefix) for all operations being added to the graph.

WARNING: The API in this package has not been finalized and can change without notice.

Example ¶
// This example creates a Graph that multiplies a constant matrix with
// a matrix to be provided during graph execution (via
// tensorflow.Session).
s := NewScope()
input := Placeholder(s, tf.Float) // Matrix to be provided to Session.Run
output := MatMul(s,
	Const(s, [][]float32{{10}, {20}}), // Constant 2x1 matrix
	input,
	MatMulTransposeB(true))
if s.Err() != nil {
	panic(s.Err())
}
// Shape of the product: The number of rows is fixed by m1, but the
// number of columns will depend on m2, which is unknown.
fmt.Println(output.Shape())
Output:

[2, ?]

Index ¶