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 cc6d8de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion efficientdet/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def __call__(self, params, input_context=None, batch_size=None):
)

batch_size = batch_size or params['batch_size']
seed = params['tf_random_seed'] if self._debug else None
seed = params.get('tf_random_seed', None)
dataset = tf.data.Dataset.list_files(
self._file_pattern, shuffle=self._is_training, seed=seed)
if input_context:
Expand Down
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 cc6d8de

Please sign in to comment.