Skip to content

Commit

Permalink
Added TensorFlow Profiler (isarandi#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
ylee-rbx authored and GitHub Enterprise committed Aug 28, 2023
1 parent 1a16a34 commit 78006a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,8 @@ def get_parser():
parser.add_argument('--model-class', type=str, default='Metrabs')
parser.add_argument('--input-float32', action=options.BoolAction, default=False)
parser.add_argument('--final-transposed-conv', type=int, default=1)
parser.add_argument('--tfprofiler', action=options.BoolAction, default=False,
help='tensorflow profiler')
parser.add_argument('--tfprofiler-dir', type=str, default='tfprofiler',
help='Directory path of tensorflow profiler.')
return parser
6 changes: 6 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ def train():
callbacks.TensorBoardCallback(global_step)
]

# `pip install -U tensorboard_plugin_profiler` or ensure the docker version metrabs:0.1.21 or higher
if FLAGS.tfprofiler:
profiler_dir = util.ensure_absolute_path(os.path.join('experiments', FLAGS.tfprofiler_dir))
c = keras.callbacks.TensorBoard(log_dir=profiler_dir, profile_batch=(30, 35))
cbacks.append(c)

if FLAGS.finetune_in_inference_mode:
switch_step = FLAGS.training_steps - FLAGS.finetune_in_inference_mode
c = callbacks.SwitchToInferenceModeCallback(global_step, switch_step)
Expand Down

0 comments on commit 78006a9

Please sign in to comment.