File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
site/en/tutorials/distribute Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 363
363
" # Define the checkpoint directory to store the checkpoints.\n " ,
364
364
" checkpoint_dir = './training_checkpoints'\n " ,
365
365
" # Define the name of the checkpoint files.\n " ,
366
- " checkpoint_prefix = os.path.join(checkpoint_dir, \" ckpt_{epoch} \" )"
366
+ " checkpoint_prefix = os.path.join(checkpoint_dir, \" ckpt_{epoch:04d}.weights.h5 \" )"
367
367
]
368
368
},
369
369
{
396
396
" # Define a callback for printing the learning rate at the end of each epoch.\n " ,
397
397
" class PrintLR(tf.keras.callbacks.Callback):\n " ,
398
398
" def on_epoch_end(self, epoch, logs=None):\n " ,
399
- " print('\\ nLearning rate for epoch {} is {}'.format( epoch + 1, model.optimizer.lr .numpy()))"
399
+ " print('\\ nLearning rate for epoch {} is {}'.format(epoch + 1, model.optimizer.learning_rate .numpy()))"
400
400
]
401
401
},
402
402
{
486
486
},
487
487
"outputs" : [],
488
488
"source" : [
489
- " model.load_weights(tf.train.latest_checkpoint(checkpoint_dir))\n " ,
489
+ " import pathlib\n " ,
490
+ " latest_checkpoint = sorted(pathlib.Path(checkpoint_dir).glob('*'))[-1]\n " ,
491
+ " \n " ,
492
+ " model.load_weights(latest_checkpoint)\n " ,
490
493
" \n " ,
491
494
" eval_loss, eval_acc = model.evaluate(eval_dataset)\n " ,
492
495
" \n " ,
You can’t perform that action at this time.
0 commit comments