Skip to content

Commit

Permalink
fix random seed
Browse files Browse the repository at this point in the history
  • Loading branch information
fsx950223 committed Feb 11, 2022
1 parent 0b0ba5e commit e7cc1eb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions efficientdet/tf2/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def define_flags():
flags.DEFINE_string('model_name', 'efficientdet-d0', 'Model name.')
flags.DEFINE_bool('debug', False, 'Enable debug mode')
flags.DEFINE_integer(
'tf_random_seed', 111111,
'tf_random_seed', None,
'Fixed random seed for deterministic execution across runs for debugging.'
)
flags.DEFINE_bool('profile', False, 'Enable profile mode')
Expand Down Expand Up @@ -163,10 +163,12 @@ def main(_):
for gpu in tf.config.list_physical_devices('GPU'):
tf.config.experimental.set_memory_growth(gpu, True)

if FLAGS.tf_random_seed:
tf.random.set_seed(FLAGS.tf_random_seed)

if FLAGS.debug:
tf.debugging.set_log_device_placement(True)
os.environ['TF_DETERMINISTIC_OPS'] = '1'
tf.random.set_seed(FLAGS.tf_random_seed)
logging.set_verbosity(logging.DEBUG)

if FLAGS.strategy == 'tpu':
Expand Down

0 comments on commit e7cc1eb

Please sign in to comment.