Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mednet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
medai
software
mednet
Commits
200a56b6
Commit
200a56b6
authored
1 year ago
by
Daniel CARRON
Browse files
Options
Downloads
Patches
Plain Diff
Custom TensorBoardLogger
parent
026ddb48
No related branches found
No related tags found
No related merge requests found
Pipeline
#75881
failed
1 year ago
Stage: qa
Stage: test
Stage: doc
Stage: dist
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ptbench/engine/loggers/custom_tensorboard_logger.py
+78
-0
78 additions, 0 deletions
src/ptbench/engine/loggers/custom_tensorboard_logger.py
src/ptbench/engine/trainer.py
+3
-1
3 additions, 1 deletion
src/ptbench/engine/trainer.py
with
81 additions
and
1 deletion
src/ptbench/engine/loggers/custom_tensorboard_logger.py
0 → 100644
+
78
−
0
View file @
200a56b6
import
os
from
typing
import
Any
,
Optional
,
Union
from
lightning.fabric.utilities.types
import
_PATH
from
lightning.pytorch.loggers
import
TensorBoardLogger
class
CustomTensorboardLogger
(
TensorBoardLogger
):
r
"""
Custom implementation implementation of
lightning.pytorch.loggers.TensorBoardLogger.
Allows us to put all logs inside the same directory, instead of a separate
"
version_n
"
directory which is the default behaviour.
Parameters
----------
save_dir:
Save directory
name:
Experiment name. Defaults to ``
'
default
'
``. If it is the empty string then no per-experiment
subdirectory is used.
version:
Experiment version. If version is not specified the logger inspects the save
directory for existing versions, then automatically assigns the next available version.
If it is a string then it is used as the run-specific subdirectory name,
otherwise ``
'
version_${version}
'
`` is used.
log_graph:
Adds the computational graph to tensorboard. This requires that
the user has defined the `self.example_input_array` attribute in their
model.
default_hp_metric:
Enables a placeholder metric with key `hp_metric` when `log_hyperparams` is
called without a metric (otherwise calls to log_hyperparams without a metric are ignored).
prefix:
A string to put at the beginning of metric keys.
sub_dir:
Sub-directory to group TensorBoard logs. If a sub_dir argument is passed
then logs are saved in ``/save_dir/name/version/sub_dir/``. Defaults to ``None`` in which
logs are saved in ``/save_dir/name/version/``.
\**kwargs:
Additional arguments used by :class:`tensorboardX.SummaryWriter` can be passed as keyword
arguments in this logger. To automatically flush to disk, `max_queue` sets the size
of the queue for pending logs before flushing. `flush_secs` determines how many seconds
elapses before flushing.
"""
def
__init__
(
self
,
save_dir
:
_PATH
,
name
:
Optional
[
str
]
=
"
lightning_logs
"
,
version
:
Optional
[
Union
[
int
,
str
]]
=
None
,
log_graph
:
bool
=
False
,
default_hp_metric
:
bool
=
True
,
prefix
:
str
=
""
,
sub_dir
:
Optional
[
_PATH
]
=
None
,
**
kwargs
:
Any
,
):
super
().
__init__
(
save_dir
,
name
,
version
,
log_graph
,
default_hp_metric
,
prefix
,
sub_dir
,
)
@property
def
log_dir
(
self
)
->
str
:
return
os
.
path
.
join
(
self
.
save_dir
,
self
.
name
)
This diff is collapsed.
Click to expand it.
src/ptbench/engine/trainer.py
+
3
−
1
View file @
200a56b6
...
...
@@ -156,8 +156,10 @@ def run(
# Save model summary
_
,
no_of_parameters
=
save_model_summary
(
output_folder
,
model
)
from
.loggers.custom_tensorboard_logger
import
CustomTensorboardLogger
log_dir
=
"
logs
"
tensorboard_logger
=
lightning
.
pytorch
.
loggers
.
Tensor
B
oardLogger
(
tensorboard_logger
=
Custom
Tensor
b
oardLogger
(
output_folder
,
log_dir
,
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment