Unverified Commit c3d2a18f authored by wawatt's avatar wawatt Committed by GitHub
Browse files


parent 7a52713b
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
'''Code adapted from https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix'''
import os
import time
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
import sys
import tf_logger
class Visualizer():
def __init__(self, opt, name='train'):
# self.opt = opt
#self.logger = tf_logger.Logger(os.path.join(opt.logging_dir, opt.name))
#self.log_name = os.path.join(opt.checkpoint_dir, opt.name, 'loss_log.txt')
self.logger = tf_logger.Logger(os.path.join(opt.log_dir, name))
self.log_name = os.path.join(opt.log_dir, 'tf_visualizer_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 save
def log_images(self, visuals, step):
for label, image_numpy in visuals.items():
label, [image_numpy], step)
# scalars: dictionary of scalar labels and values
def log_scalars(self, scalars, step):
for label, val in scalars.items():
self.logger.scalar_summary(label, val, step)
# scatter plots
def plot_current_points(self, points, disp_offset=10):
# scalars: same format as |scalars| of plot_current_scalars
def print_current_scalars(self, epoch, i, scalars):
message = '(epoch: %d, iters: %d) ' % (epoch, i)
for k, v in scalars.items():
message += '%s: %.3f ' % (k, v)
with open(self.log_name, "a") as log_file:
log_file.write('%s\n' % message)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment