Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andrei-Claudiu Roibu
BrainMapper
Commits
f5c757b6
Commit
f5c757b6
authored
May 29, 2020
by
Andrei-Claudiu Roibu
🖥
Browse files
loss per epoch is not the mean, absolute change is printed
parent
a817b485
Changes
1
Hide whitespace changes
Inline
Side-by-side
utils/data_logging_utils.py
View file @
f5c757b6
...
...
@@ -109,7 +109,7 @@ class LogWriter():
self
.
log_writer
[
'train'
].
add_scalar
(
'loss/iteration'
,
loss_per_iteration
,
iteration
)
def
loss_per_epoch
(
self
,
losses
,
phase
,
epoch
):
def
loss_per_epoch
(
self
,
losses
,
phase
,
epoch
,
previous_loss
=
None
):
"""Log function
This function records the loss for every epoch.
...
...
@@ -118,14 +118,21 @@ class LogWriter():
losses (list): Values of all the losses recorded during the training epoch
phase (str): Current run mode or phase
epoch (int): Current epoch value
previous_loss(float): Value of the previous epoch's loss
"""
loss
=
np
.
mean
(
losses
)
if
phase
==
'train'
:
loss
=
losses
[
-
1
]
# loss = losses[-1]
print
(
"Loss for Epoch {} of {} is: {}"
.
format
(
epoch
,
phase
,
loss
))
else
:
loss
=
np
.
mean
(
losses
)
# loss = np.mean(losses)
if
previous_loss
==
None
:
print
(
"Loss for Epoch {} of {} is: {}"
.
format
(
epoch
,
phase
,
loss
))
else
:
print
(
"Loss for Epoch {} of {} is {} and Absolute Change is {}"
.
format
(
epoch
,
phase
,
loss
,
previous_loss
-
loss
))
print
(
"Loss for Epoch {} of {} is: {}"
.
format
(
epoch
,
phase
,
loss
))
self
.
log_writer
[
phase
].
add_scalar
(
'loss/epoch'
,
loss
,
epoch
)
def
close
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment