Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hyunji
/
A-Performance-Evaluation-of-CNN-for-Brain-Age-Prediction-Using-Structural-MRI-Data
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Hyunji
2021-12-20 04:22:47 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
942e3478fb95b23fc1e012ba7084bbf05e81f7cf
942e3478
1 parent
acc02096
logging
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
2DCNN/lib/utils/logging.py
2DCNN/lib/utils/logging.py
0 → 100644
View file @
942e347
""" logging related functionality """
import
logging
from
torch.utils.tensorboard
import
SummaryWriter
logger
=
logging
.
getLogger
()
def
print_verbose
(
string
,
verbose
):
if
verbose
:
print
(
string
)
def
loss_logger_helper
(
loss
,
aux_loss
,
writer
:
SummaryWriter
,
step
:
int
,
epoch
:
int
,
log_every
:
int
,
string
:
str
=
"train"
,
force_print
:
bool
=
False
,
new_line
:
bool
=
False
):
# write to tensorboard at every step but only print at log step or when force_print is passed
writer
.
add_scalar
(
f
"{string}/loss"
,
loss
,
step
)
for
k
,
v
in
aux_loss
.
items
():
writer
.
add_scalar
(
f
"{string}/"
+
k
,
v
,
step
)
if
step
%
log_every
==
0
or
force_print
:
logger
.
info
(
f
"{string}/loss: ({step}/{epoch}) {loss}"
)
if
force_print
:
if
new_line
:
for
k
,
v
in
aux_loss
.
items
():
logger
.
info
(
f
"{string}/{k}:{v} "
)
else
:
str_
=
""
for
k
,
v
in
aux_loss
.
items
():
str_
+=
f
"{string}/{k}:{v} "
logger
.
info
(
f
"{str_}"
)
Please
register
or
login
to post a comment