tf.compat.v1.train.Scaffold

View source on GitHub

Structure to create or gather pieces commonly needed to train a model.

tf.compat.v1.train.Scaffold(
    init_op=None, init_feed_dict=None, init_fn=None, ready_op=None,
    ready_for_local_init_op=None, local_init_op=None, summary_op=None, saver=None,
    copy_from_scaffold=None, local_init_feed_dict=None
)

When you build a model for training you usually need ops to initialize variables, a Saver to checkpoint them, an op to collect summaries for the visualizer, and so on.

Various libraries built on top of the core TensorFlow library take care of creating some or all of these pieces and storing them in well known collections in the graph. The Scaffold class helps pick these pieces from the graph collections, creating and adding them to the collections if needed.

If you call the scaffold constructor without any arguments, it will pick pieces from the collections, creating default ones if needed when scaffold.finalize() is called. You can pass arguments to the constructor to provide your own pieces. Pieces that you pass to the constructor are not added to the graph collections.

The following pieces are directly accessible as attributes of the Scaffold object:

You can also pass the following additional pieces to the constructor:

Args:

Attributes:

Methods

default_local_init_op

View source

@staticmethod
default_local_init_op()

Returns an op that groups the default local init ops.

This op is used during session initialization when a Scaffold is initialized without specifying the local_init_op arg. It includes tf.compat.v1.local_variables_initializer, tf.compat.v1.tables_initializer, and also initializes local session resources.

Returns:

The default Scaffold local init op.

finalize

View source

finalize()

Creates operations if needed and finalizes the graph.

get_or_default

View source

@staticmethod
get_or_default(
    arg_name, collection_key, default_constructor
)

Get from cache or create a default operation.