Skip to content

Commit

Permalink
save training losses to the file (log_file.txt)
Browse files Browse the repository at this point in the history
  • Loading branch information
junyanz committed Jun 13, 2017
1 parent 437648f commit 3b72a65
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion util/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ def __init__(self, opt):
self.img_dir = os.path.join(self.web_dir, 'images')
print('create web directory %s...' % self.web_dir)
util.mkdirs([self.web_dir, self.img_dir])

self.log_name = os.path.join(opt.checkpoints_dir, opt.name, 'loss_log.txt')
with open(self.log_name, "a") as log_file:
now = time.strftime("%c")
log_file.write('================ Training Loss (%s) ================\n' % now)

# |visuals|: dictionary of images to display or save
def display_current_results(self, visuals, epoch):
Expand Down Expand Up @@ -76,6 +79,8 @@ def print_current_errors(self, epoch, i, errors, t):
message += '%s: %.3f ' % (k, v)

print(message)
with open(self.log_name, "a") as log_file:
log_file.write('%s\n' % message)

# save image to the disk
def save_images(self, webpage, visuals, image_path):
Expand Down

0 comments on commit 3b72a65

Please sign in to comment.