Python utils.variables_to_restore() Examples
The following are 9
code examples of utils.variables_to_restore().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
utils
, or try the search function
.
Example #1
Source File: model.py From DOTA_models with Apache License 2.0 | 5 votes |
def create_init_fn_to_restore(self, master_checkpoint, inception_checkpoint): """Creates an init operations to restore weights from various checkpoints. Args: master_checkpoint: path to a checkpoint which contains all weights for the whole model. inception_checkpoint: path to a checkpoint which contains weights for the inception part only. Returns: a function to run initialization ops. """ all_assign_ops = [] all_feed_dict = {} def assign_from_checkpoint(variables, checkpoint): logging.info('Request to re-store %d weights from %s', len(variables), checkpoint) if not variables: logging.error('Can\'t find any variables to restore.') sys.exit(1) assign_op, feed_dict = slim.assign_from_checkpoint(checkpoint, variables) all_assign_ops.append(assign_op) all_feed_dict.update(feed_dict) if master_checkpoint: assign_from_checkpoint(utils.variables_to_restore(), master_checkpoint) if inception_checkpoint: variables = utils.variables_to_restore( 'AttentionOcr_v1/conv_tower_fn/INCE', strip_scope=True) assign_from_checkpoint(variables, inception_checkpoint) def init_assign_fn(sess): logging.info('Restoring checkpoint(s)') sess.run(all_assign_ops, all_feed_dict) return init_assign_fn
Example #2
Source File: model.py From hands-detection with MIT License | 5 votes |
def create_init_fn_to_restore(self, master_checkpoint, inception_checkpoint): """Creates an init operations to restore weights from various checkpoints. Args: master_checkpoint: path to a checkpoint which contains all weights for the whole model. inception_checkpoint: path to a checkpoint which contains weights for the inception part only. Returns: a function to run initialization ops. """ all_assign_ops = [] all_feed_dict = {} def assign_from_checkpoint(variables, checkpoint): logging.info('Request to re-store %d weights from %s', len(variables), checkpoint) if not variables: logging.error('Can\'t find any variables to restore.') sys.exit(1) assign_op, feed_dict = slim.assign_from_checkpoint(checkpoint, variables) all_assign_ops.append(assign_op) all_feed_dict.update(feed_dict) if master_checkpoint: assign_from_checkpoint(utils.variables_to_restore(), master_checkpoint) if inception_checkpoint: variables = utils.variables_to_restore( 'AttentionOcr_v1/conv_tower_fn/INCE', strip_scope=True) assign_from_checkpoint(variables, inception_checkpoint) def init_assign_fn(sess): logging.info('Restoring checkpoint(s)') sess.run(all_assign_ops, all_feed_dict) return init_assign_fn
Example #3
Source File: model.py From object_detection_kitti with Apache License 2.0 | 5 votes |
def create_init_fn_to_restore(self, master_checkpoint, inception_checkpoint=None): """Creates an init operations to restore weights from various checkpoints. Args: master_checkpoint: path to a checkpoint which contains all weights for the whole model. inception_checkpoint: path to a checkpoint which contains weights for the inception part only. Returns: a function to run initialization ops. """ all_assign_ops = [] all_feed_dict = {} def assign_from_checkpoint(variables, checkpoint): logging.info('Request to re-store %d weights from %s', len(variables), checkpoint) if not variables: logging.error('Can\'t find any variables to restore.') sys.exit(1) assign_op, feed_dict = slim.assign_from_checkpoint(checkpoint, variables) all_assign_ops.append(assign_op) all_feed_dict.update(feed_dict) if master_checkpoint: assign_from_checkpoint(utils.variables_to_restore(), master_checkpoint) if inception_checkpoint: variables = utils.variables_to_restore( 'AttentionOcr_v1/conv_tower_fn/INCE', strip_scope=True) assign_from_checkpoint(variables, inception_checkpoint) def init_assign_fn(sess): logging.info('Restoring checkpoint(s)') sess.run(all_assign_ops, all_feed_dict) return init_assign_fn
Example #4
Source File: model.py From object_detection_with_tensorflow with MIT License | 5 votes |
def create_init_fn_to_restore(self, master_checkpoint, inception_checkpoint=None): """Creates an init operations to restore weights from various checkpoints. Args: master_checkpoint: path to a checkpoint which contains all weights for the whole model. inception_checkpoint: path to a checkpoint which contains weights for the inception part only. Returns: a function to run initialization ops. """ all_assign_ops = [] all_feed_dict = {} def assign_from_checkpoint(variables, checkpoint): logging.info('Request to re-store %d weights from %s', len(variables), checkpoint) if not variables: logging.error('Can\'t find any variables to restore.') sys.exit(1) assign_op, feed_dict = slim.assign_from_checkpoint(checkpoint, variables) all_assign_ops.append(assign_op) all_feed_dict.update(feed_dict) if master_checkpoint: assign_from_checkpoint(utils.variables_to_restore(), master_checkpoint) if inception_checkpoint: variables = utils.variables_to_restore( 'AttentionOcr_v1/conv_tower_fn/INCE', strip_scope=True) assign_from_checkpoint(variables, inception_checkpoint) def init_assign_fn(sess): logging.info('Restoring checkpoint(s)') sess.run(all_assign_ops, all_feed_dict) return init_assign_fn
Example #5
Source File: model.py From yolo_v2 with Apache License 2.0 | 4 votes |
def create_init_fn_to_restore(self, master_checkpoint, inception_checkpoint=None): """Creates an init operations to restore weights from various checkpoints. Args: master_checkpoint: path to a checkpoint which contains all weights for the whole model. inception_checkpoint: path to a checkpoint which contains weights for the inception part only. Returns: a function to run initialization ops. """ all_assign_ops = [] all_feed_dict = {} def assign_from_checkpoint(variables, checkpoint): logging.info('Request to re-store %d weights from %s', len(variables), checkpoint) if not variables: logging.error('Can\'t find any variables to restore.') sys.exit(1) assign_op, feed_dict = slim.assign_from_checkpoint(checkpoint, variables) all_assign_ops.append(assign_op) all_feed_dict.update(feed_dict) logging.info('variables_to_restore:\n%s' % utils.variables_to_restore().keys()) logging.info('moving_average_variables:\n%s' % [v.op.name for v in tf.moving_average_variables()]) logging.info('trainable_variables:\n%s' % [v.op.name for v in tf.trainable_variables()]) if master_checkpoint: assign_from_checkpoint(utils.variables_to_restore(), master_checkpoint) if inception_checkpoint: variables = utils.variables_to_restore( 'AttentionOcr_v1/conv_tower_fn/INCE', strip_scope=True) assign_from_checkpoint(variables, inception_checkpoint) def init_assign_fn(sess): logging.info('Restoring checkpoint(s)') sess.run(all_assign_ops, all_feed_dict) return init_assign_fn
Example #6
Source File: model.py From Gun-Detector with Apache License 2.0 | 4 votes |
def create_init_fn_to_restore(self, master_checkpoint, inception_checkpoint=None): """Creates an init operations to restore weights from various checkpoints. Args: master_checkpoint: path to a checkpoint which contains all weights for the whole model. inception_checkpoint: path to a checkpoint which contains weights for the inception part only. Returns: a function to run initialization ops. """ all_assign_ops = [] all_feed_dict = {} def assign_from_checkpoint(variables, checkpoint): logging.info('Request to re-store %d weights from %s', len(variables), checkpoint) if not variables: logging.error('Can\'t find any variables to restore.') sys.exit(1) assign_op, feed_dict = slim.assign_from_checkpoint(checkpoint, variables) all_assign_ops.append(assign_op) all_feed_dict.update(feed_dict) logging.info('variables_to_restore:\n%s' % utils.variables_to_restore().keys()) logging.info('moving_average_variables:\n%s' % [v.op.name for v in tf.moving_average_variables()]) logging.info('trainable_variables:\n%s' % [v.op.name for v in tf.trainable_variables()]) if master_checkpoint: assign_from_checkpoint(utils.variables_to_restore(), master_checkpoint) if inception_checkpoint: variables = utils.variables_to_restore( 'AttentionOcr_v1/conv_tower_fn/INCE', strip_scope=True) assign_from_checkpoint(variables, inception_checkpoint) def init_assign_fn(sess): logging.info('Restoring checkpoint(s)') sess.run(all_assign_ops, all_feed_dict) return init_assign_fn
Example #7
Source File: model.py From g-tensorflow-models with Apache License 2.0 | 4 votes |
def create_init_fn_to_restore(self, master_checkpoint, inception_checkpoint=None): """Creates an init operations to restore weights from various checkpoints. Args: master_checkpoint: path to a checkpoint which contains all weights for the whole model. inception_checkpoint: path to a checkpoint which contains weights for the inception part only. Returns: a function to run initialization ops. """ all_assign_ops = [] all_feed_dict = {} def assign_from_checkpoint(variables, checkpoint): logging.info('Request to re-store %d weights from %s', len(variables), checkpoint) if not variables: logging.error('Can\'t find any variables to restore.') sys.exit(1) assign_op, feed_dict = slim.assign_from_checkpoint(checkpoint, variables) all_assign_ops.append(assign_op) all_feed_dict.update(feed_dict) logging.info('variables_to_restore:\n%s' % utils.variables_to_restore().keys()) logging.info('moving_average_variables:\n%s' % [v.op.name for v in tf.moving_average_variables()]) logging.info('trainable_variables:\n%s' % [v.op.name for v in tf.trainable_variables()]) if master_checkpoint: assign_from_checkpoint(utils.variables_to_restore(), master_checkpoint) if inception_checkpoint: variables = utils.variables_to_restore( 'AttentionOcr_v1/conv_tower_fn/INCE', strip_scope=True) assign_from_checkpoint(variables, inception_checkpoint) def init_assign_fn(sess): logging.info('Restoring checkpoint(s)') sess.run(all_assign_ops, all_feed_dict) return init_assign_fn
Example #8
Source File: model.py From models with Apache License 2.0 | 4 votes |
def create_init_fn_to_restore(self, master_checkpoint, inception_checkpoint=None): """Creates an init operations to restore weights from various checkpoints. Args: master_checkpoint: path to a checkpoint which contains all weights for the whole model. inception_checkpoint: path to a checkpoint which contains weights for the inception part only. Returns: a function to run initialization ops. """ all_assign_ops = [] all_feed_dict = {} def assign_from_checkpoint(variables, checkpoint): logging.info('Request to re-store %d weights from %s', len(variables), checkpoint) if not variables: logging.error('Can\'t find any variables to restore.') sys.exit(1) assign_op, feed_dict = slim.assign_from_checkpoint(checkpoint, variables) all_assign_ops.append(assign_op) all_feed_dict.update(feed_dict) logging.info('variables_to_restore:\n%s' % utils.variables_to_restore().keys()) logging.info('moving_average_variables:\n%s' % [v.op.name for v in tf.moving_average_variables()]) logging.info('trainable_variables:\n%s' % [v.op.name for v in tf.trainable_variables()]) if master_checkpoint: assign_from_checkpoint(utils.variables_to_restore(), master_checkpoint) if inception_checkpoint: variables = utils.variables_to_restore( 'AttentionOcr_v1/conv_tower_fn/INCE', strip_scope=True) assign_from_checkpoint(variables, inception_checkpoint) def init_assign_fn(sess): logging.info('Restoring checkpoint(s)') sess.run(all_assign_ops, all_feed_dict) return init_assign_fn
Example #9
Source File: model.py From multilabel-image-classification-tensorflow with MIT License | 4 votes |
def create_init_fn_to_restore(self, master_checkpoint, inception_checkpoint=None): """Creates an init operations to restore weights from various checkpoints. Args: master_checkpoint: path to a checkpoint which contains all weights for the whole model. inception_checkpoint: path to a checkpoint which contains weights for the inception part only. Returns: a function to run initialization ops. """ all_assign_ops = [] all_feed_dict = {} def assign_from_checkpoint(variables, checkpoint): logging.info('Request to re-store %d weights from %s', len(variables), checkpoint) if not variables: logging.error('Can\'t find any variables to restore.') sys.exit(1) assign_op, feed_dict = slim.assign_from_checkpoint(checkpoint, variables) all_assign_ops.append(assign_op) all_feed_dict.update(feed_dict) logging.info('variables_to_restore:\n%s' % utils.variables_to_restore().keys()) logging.info('moving_average_variables:\n%s' % [v.op.name for v in tf.moving_average_variables()]) logging.info('trainable_variables:\n%s' % [v.op.name for v in tf.trainable_variables()]) if master_checkpoint: assign_from_checkpoint(utils.variables_to_restore(), master_checkpoint) if inception_checkpoint: variables = utils.variables_to_restore( 'AttentionOcr_v1/conv_tower_fn/INCE', strip_scope=True) assign_from_checkpoint(variables, inception_checkpoint) def init_assign_fn(sess): logging.info('Restoring checkpoint(s)') sess.run(all_assign_ops, all_feed_dict) return init_assign_fn