Fix MAX_STEPS = 0 error by add suggestion and exit
## What this patch does to fix the issue.
Change the minimum no. of `MAX_STEPS` to 1.
## Link to any relevant issues or pull requests.
from datetime import datetime
import math
import os
+import sys
import tensorflow as tf
from tensorflow.core.util.event_pb2 import SessionLog
@@ -192,8 +193,14 @@ def start_training(config, profile_step):
# Calculate max steps. The priority of config.MAX_EPOCHS is higher than config.MAX_STEPS.
if "MAX_EPOCHS" in config:
max_steps = int(train_dataset.num_per_epoch / config.BATCH_SIZE * config.MAX_EPOCHS)
+ if max_steps < 1:
+ print("The max_steps is less than 1, consider reduce BATCH_SIZE. exit.", file=sys.stderr)
+ sys.exit(1)
else:
max_steps = config.MAX_STEPS
+ if max_steps < 1:
+ print("The max_steps is less than 1, consider set MAX_STEPS greater than 0. exit.", file=sys.stderr)
+ sys.exit(1)
progbar = Progbar(max_steps)
if rank == 0:
