tf.compat.v1.train.Scaffold

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

Used in the notebooks

Used in the guide

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:

  • saver: A tf.compat.v1.train.Saver object taking care of saving the variables. Picked from and stored into the SAVERS collection in the graph by default.
  • init_op: An op to run to initialize the variables. Picked from and stored into the INIT_OP collection in the graph by default.
  • ready_op: An op to verify that the variables are initialized. Picked from and stored into the READY_OP collection in the graph by default.
  • ready_for_local_init_op: An op to verify that glob