Load tensorflow model checkpoint
(sess, saver, checkpoint_dir, name)
| 213 | |
| 214 | |
| 215 | def load(sess, saver, checkpoint_dir, name): |
| 216 | """Load tensorflow model checkpoint""" |
| 217 | print(" [*] Reading checkpoints: {}".format(checkpoint_dir)) |
| 218 | |
| 219 | model_dir = name |
| 220 | checkpoint_dir = os.path.join(checkpoint_dir, model_dir) |
| 221 | |
| 222 | ckpt = tf.train.get_checkpoint_state(checkpoint_dir) |
| 223 | if ckpt and ckpt.model_checkpoint_path: |
| 224 | ckpt_name = os.path.basename(ckpt.model_checkpoint_path) |
| 225 | saver.restore(sess, os.path.join(checkpoint_dir, ckpt_name)) |
| 226 | print(" [*] Checkpoints read: {}".format(ckpt_name)) |
| 227 | return True |
| 228 | else: |
| 229 | print(" [!] Failed reading.") |
| 230 | return False |