Categories &

Functions List

Class Definition: TF_Graph

tensorflow: TF_Graph

A TensorFlow Graph, holding the operations a Session executes.

A TF_Graph owns the Graph it wraps and releases it when the object is destroyed. A TF_Session keeps a reference to the Graph it was created over, so a Graph is never released while a Session still needs it, whatever order the variables are cleared in.

Source Code: TF_Graph

The TF_Graph class contains the following properties:

The TF_Graph class offers the following public methods:

TF_Graph: obj = TF_Graph ()

TF_Graph: names = operationNames (obj)

The graph of a loaded model can be inspected, which is how the operations to feed and to read are found when a model does not follow the usual names. Placeholders are fed; here serving_default_x is the model input and saver_filename belongs to the checkpoint saver.

 sess = TF_Session.fromSavedModel (__tf_test_model__ ());
 names = sess.Graph.operationNames ();
 types = sess.Graph.operationTypes ();
 names(strcmp (types, "Placeholder"))
ans =
{
  [1,1] = serving_default_x
  [1,2] = saver_filename
}

Every operation of the graph, with its type.

 sess = TF_Session.fromSavedModel (__tf_test_model__ ());
 names = sess.Graph.operationNames ();
 types = sess.Graph.operationTypes ();
 for i = 1:numel (names)
   printf ("%-32s %s\n", names{i}, types{i});
 endfor
b                                VarHandleOp
b/Read/ReadVariableOp            ReadVariableOp
w                                VarHandleOp
w/Read/ReadVariableOp            ReadVariableOp
serving_default_x                Placeholder
StatefulPartitionedCall          StatefulPartitionedCall
NoOp                             NoOp
Const                            Const
saver_filename                   Placeholder
StatefulPartitionedCall_1        StatefulPartitionedCall
StatefulPartitionedCall_2        StatefulPartitionedCall
TF_Graph: types = operationTypes (obj)

TF_Graph: tf = hasOperation (obj, name)

TF_Graph: n = numOutputs (obj, name)

TF_Graph: delete (obj)

This is called automatically when no variable refers to the object any more, and calling it a second time does nothing.