We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents fe040db + 2f7592f commit dd0a65eCopy full SHA for dd0a65e
site/en/tutorials/keras/save_and_load.ipynb
@@ -385,12 +385,17 @@
385
"\n",
386
"batch_size = 32\n",
387
388
+ "# Calculate the number of batches per epoch\n",
389
+ "import math\n",
390
+ "n_batches = len(train_images) / batch_size\n",
391
+ "n_batches = math.ceil(n_batches) # round up the number of batches to the nearest whole integer\n",
392
+ "\n",
393
"# Create a callback that saves the model's weights every 5 epochs\n",
394
"cp_callback = tf.keras.callbacks.ModelCheckpoint(\n",
395
" filepath=checkpoint_path, \n",
396
" verbose=1, \n",
397
" save_weights_only=True,\n",
- " save_freq=5*batch_size)\n",
398
+ " save_freq=5*n_batches)\n",
399
400
"# Create a new model instance\n",
401
"model = create_model()\n",
0 commit comments