Python tensorboardX.SummaryWriter() Examples

The following are 30 code examples of tensorboardX.SummaryWriter(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tensorboardX , or try the search function .
Example #1
Source File: main.py    From Extremely-Fine-Grained-Entity-Typing with MIT License 6 votes vote down vote up
def visualize(args):
  saved_path = constant.EXP_ROOT
  model = models.Model(args, constant.ANSWER_NUM_DICT[args.goal])
  model.cuda()
  model.eval()
  model.load_state_dict(torch.load(saved_path + '/' + args.model_id + '_best.pt')["state_dict"])

  label2id = constant.ANS2ID_DICT["open"] 
  visualize = SummaryWriter("../visualize/" + args.model_id)
  # label_list = ["person", "leader", "president", "politician", "organization", "company", "athlete","adult",  "male",  "man", "television_program", "event"]
  label_list = list(label2id.keys())
  ids = [label2id[_] for _ in label_list]
  if args.gcn:
    # connection_matrix = model.decoder.label_matrix + model.decoder.weight * model.decoder.affinity
    connection_matrix = model.decoder.label_matrix + model.decoder.weight * model.decoder.affinity
    label_vectors = model.decoder.transform(connection_matrix.mm(model.decoder.linear.weight) / connection_matrix.sum(1, keepdim=True))
  else:
    label_vectors = model.decoder.linear.weight.data

  interested_vectors = torch.index_select(label_vectors, 0, torch.tensor(ids).to(torch.device("cuda")))
  visualize.add_embedding(interested_vectors, metadata=label_list, label_img=None) 
Example #2
Source File: experiments.py    From pytorch-deep-sets with MIT License 6 votes vote down vote up
def __init__(self, lr=1e-3, wd=5e-3):
        self.lr = lr
        self.wd = wd
        self.train_db = MNISTSummation(min_len=2, max_len=10, dataset_len=100000, train=True, transform=MNIST_TRANSFORM)
        self.test_db = MNISTSummation(min_len=5, max_len=50, dataset_len=100000, train=False, transform=MNIST_TRANSFORM)

        self.the_phi = SmallMNISTCNNPhi()
        self.the_rho = SmallRho(input_size=10, output_size=1)

        self.model = InvariantModel(phi=self.the_phi, rho=self.the_rho)
        if torch.cuda.is_available():
            self.model.cuda()

        self.optimizer = optim.Adam(self.model.parameters(), lr=self.lr, weight_decay=self.wd)

        self.summary_writer = SummaryWriter(
            log_dir='/home/souri/temp/deepsets/exp-lr:%1.5f-wd:%1.5f/' % (self.lr, self.wd)) 
Example #3
Source File: tensorboard.py    From neural-pipeline with MIT License 6 votes vote down vote up
def __init__(self, fsm: FileStructManager, is_continue: bool, network_name: str = None):
        super().__init__()
        self.__writer = None
        self.__txt_log_file = None

        fsm.register_dir(self)
        dir = fsm.get_path(self)
        if dir is None:
            return

        dir = os.path.join(dir, network_name) if network_name is not None else dir

        if not (fsm.in_continue_mode() or is_continue) and os.path.exists(dir) and os.path.isdir(dir):
            idx = 0
            tmp_dir = dir + "_v{}".format(idx)
            while os.path.exists(tmp_dir) and os.path.isdir(tmp_dir):
                idx += 1
                tmp_dir = dir + "_v{}".format(idx)
            dir = tmp_dir

        os.makedirs(dir, exist_ok=True)
        self.__writer = SummaryWriter(dir)
        self.__txt_log_file = open(os.path.join(dir, "log.txt"), 'a' if is_continue else 'w') 
Example #4
Source File: nvll.py    From vmf_vae_nlp with MIT License 6 votes vote down vote up
def set_save_name_log_nvrnn(args):
    args.save_name = os.path.join(
        args.exp_path, 'Data{}_' \
                       'Dist{}_Model{}_Enc{}Bi{}_Emb{}_Hid{}_lat{}_lr{}_drop{}_kappa{}_auxw{}_normf{}_nlay{}_mixunk{}_inpz{}_cdbit{}_cdbow{}_ann{}'
            .format(
            args.data_name, str(args.dist), args.model, args.enc_type, args.bi,
            args.emsize,
            args.nhid, args.lat_dim, args.lr,
            args.dropout, args.kappa, args.aux_weight, str(args.norm_func), args.nlayers, args.mix_unk, args.input_z,
            args.cd_bit, args.cd_bow, args.anneal))
    writer = SummaryWriter(log_dir=args.save_name)
    log_name = args.save_name + '.log'
    logging.basicConfig(filename=log_name, level=logging.INFO)
    # set up logging to console
    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    # set a format which is simpler for console use
    formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
    console.setFormatter(formatter)
    # add the handler to the root logger
    logging.getLogger('').addHandler(console)
    return args, writer 
Example #5
Source File: nvll.py    From vmf_vae_nlp with MIT License 6 votes vote down vote up
def set_save_name_log_nvdm(args):
    args.save_name = os.path.join(args.root_path, args.exp_path,
                                  'Data{}_Dist{}_Model{}_Emb{}_Hid{}_lat{}_lr{}_drop{}_kappa{}_auxw{}_normf{}'
                                  .format(
                                      args.data_name, str(args.dist), args.model,
                                      args.emsize,
                                      args.nhid, args.lat_dim, args.lr,
                                      args.dropout, args.kappa, args.aux_weight, str(args.norm_func)))
    writer = SummaryWriter(log_dir=args.save_name)
    log_name = args.save_name + '.log'
    logging.basicConfig(filename=log_name, level=logging.INFO)
    # set up logging to console
    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    # set a format which is simpler for console use
    formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
    console.setFormatter(formatter)
    # add the handler to the root logger
    logging.getLogger('').addHandler(console)
    return args, writer 
Example #6
Source File: tensorboard_logger.py    From Human-Pose-Transfer with MIT License 6 votes vote down vote up
def __init__(self, log_dir):
        try:
            from torch.utils.tensorboard import SummaryWriter
        except ImportError:
            try:
                from tensorboardX import SummaryWriter
            except ImportError:
                raise RuntimeError("This contrib module requires tensorboardX to be installed. "
                                   "Please install it with command: \n pip install tensorboardX")

        try:
            self.writer = SummaryWriter(log_dir)
        except TypeError as err:
            if "type object got multiple values for keyword argument 'logdir'" == str(err):
                self.writer = SummaryWriter(log_dir=log_dir)
                warnings.warn('tensorboardX version < 1.7 will not be supported '
                              'after ignite 0.3.0; please upgrade',
                              DeprecationWarning)
            else:
                raise err 
Example #7
Source File: train.py    From yolo2-pytorch with GNU Lesser General Public License v3.0 6 votes vote down vote up
def run(self):
        self.writer = SummaryWriter(os.path.join(self.env.model_dir, self.env.args.run))
        try:
            height, width = tuple(map(int, self.config.get('image', 'size').split()))
            tensor = torch.randn(1, 3, height, width)
            step, epoch, dnn = self.env.load()
            self.writer.add_graph(dnn, (torch.autograd.Variable(tensor),))
        except:
            traceback.print_exc()
        while True:
            name, kwargs = self.queue.get()
            if name is None:
                break
            func = getattr(self, 'summary_' + name)
            try:
                func(**kwargs)
            except:
                traceback.print_exc() 
Example #8
Source File: DDPG.py    From Deep-reinforcement-learning-with-pytorch with MIT License 6 votes vote down vote up
def __init__(self, state_dim, action_dim, max_action):
        self.actor = Actor(state_dim, action_dim, max_action).to(device)
        self.actor_target = Actor(state_dim, action_dim, max_action).to(device)
        self.actor_target.load_state_dict(self.actor.state_dict())
        self.actor_optimizer = optim.Adam(self.actor.parameters(), lr=1e-4)

        self.critic = Critic(state_dim, action_dim).to(device)
        self.critic_target = Critic(state_dim, action_dim).to(device)
        self.critic_target.load_state_dict(self.critic.state_dict())
        self.critic_optimizer = optim.Adam(self.critic.parameters(), lr=1e-3)
        self.replay_buffer = Replay_buffer()
        self.writer = SummaryWriter(directory)

        self.num_critic_update_iteration = 0
        self.num_actor_update_iteration = 0
        self.num_training = 0 
Example #9
Source File: report_manager.py    From ITDD with MIT License 6 votes vote down vote up
def build_report_manager(opt):
    if opt.tensorboard:
        from tensorboardX import SummaryWriter
        tensorboard_log_dir = opt.tensorboard_log_dir

        if not opt.train_from:
            tensorboard_log_dir += datetime.now().strftime("/%b-%d_%H-%M-%S")

        writer = SummaryWriter(tensorboard_log_dir,
                               comment="Unmt")
    else:
        writer = None

    report_mgr = ReportMgr(opt.report_every, start_time=-1,
                           tensorboard_writer=writer)
    return report_mgr 
Example #10
Source File: TD3.py    From Deep-reinforcement-learning-with-pytorch with MIT License 6 votes vote down vote up
def __init__(self, state_dim, action_dim, max_action):

        self.actor = Actor(state_dim, action_dim, max_action).to(device)
        self.actor_target = Actor(state_dim, action_dim, max_action).to(device)
        self.critic_1 = Critic(state_dim, action_dim).to(device)
        self.critic_1_target = Critic(state_dim, action_dim).to(device)
        self.critic_2 = Critic(state_dim, action_dim).to(device)
        self.critic_2_target = Critic(state_dim, action_dim).to(device)

        self.actor_optimizer = optim.Adam(self.actor.parameters())
        self.critic_1_optimizer = optim.Adam(self.critic_1.parameters())
        self.critic_2_optimizer = optim.Adam(self.critic_2.parameters())

        self.actor_target.load_state_dict(self.actor.state_dict())
        self.critic_1_target.load_state_dict(self.critic_1.state_dict())
        self.critic_2_target.load_state_dict(self.critic_2.state_dict())

        self.max_action = max_action
        self.memory = Replay_buffer(args.capacity)
        self.writer = SummaryWriter(directory)
        self.num_critic_update_iteration = 0
        self.num_actor_update_iteration = 0
        self.num_training = 0 
Example #11
Source File: safelife_logger.py    From safelife with Apache License 2.0 6 votes vote down vote up
def init_logdir(self):
        if not self._has_init and self.logdir:
            if self.testing_log:
                self._testing_log = StreamingJSONWriter(
                    os.path.join(self.logdir, self.testing_log))
            if self.training_log:
                self._training_log = StreamingJSONWriter(
                    os.path.join(self.logdir, self.training_log))
            if self.summary_writer is None:
                try:
                    from tensorboardX import SummaryWriter
                    self.summary_writer = SummaryWriter(self.logdir)
                except ImportError:
                    logger.error(
                        "Could not import tensorboardX. "
                        "SafeLifeLogger will not write data to tensorboard.")
        self._has_init = True 
Example #12
Source File: solver.py    From Tacotron-pytorch with MIT License 6 votes vote down vote up
def __init__(self, config, args):
        super(Trainer, self).__init__(config, args)
        # Best validation error, initialize it with a large number
        self.best_val_err = 1e10
        # Logger Settings
        name = Path(args.checkpoint_dir).stem
        self.log_dir = str(Path(args.log_dir, name))
        self.log_writer = SummaryWriter(self.log_dir)
        self.checkpoint_path = args.checkpoint_path
        self.checkpoint_dir = args.checkpoint_dir
        os.makedirs(self.checkpoint_dir, exist_ok=True)

        self.config = config
        self.audio_processor = AudioProcessor(**config['audio'])
        # Training detail
        self.step = 0
        self.max_step = config['solver']['total_steps'] 
Example #13
Source File: run_molecule.py    From rl_graph_generation with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def main():
    args = molecule_arg_parser().parse_args()
    print(args)
    args.name_full = args.env + '_' + args.dataset + '_' + args.name
    args.name_full_load = args.env + '_' + args.dataset_load + '_' + args.name_load + '_' + str(args.load_step)
    # check and clean
    if not os.path.exists('molecule_gen'):
        os.makedirs('molecule_gen')
    if not os.path.exists('ckpt'):
        os.makedirs('ckpt')

    # only keep first worker result in tensorboard
    if MPI.COMM_WORLD.Get_rank() == 0:
        writer = SummaryWriter(comment='_'+args.dataset+'_'+args.name)
    else:
        writer = None
    train(args,seed=args.seed,writer=writer) 
Example #14
Source File: evaluator.py    From MazeExplorer with MIT License 6 votes vote down vote up
def __init__(self, mazes_path, tensorboard_dir, vector_length, mp, n_stack, action_frame_repeat=4,
                 scaled_resolution=(42, 42)):

        self.tensorboard_dir = tensorboard_dir

        mazes_folders = [(x, os.path.join(mazes_path, x)) for x in os.listdir(mazes_path)]
        get_cfg = lambda x: os.path.join(x, [cfg for cfg in sorted(os.listdir(x)) if cfg.endswith('.cfg')][0])
        self.eval_cfgs = [(x[0], get_cfg(x[1])) for x in mazes_folders]

        if not len(self.eval_cfgs):
            raise FileNotFoundError("No eval cfgs found")

        number_maps = 1  # number of maps inside each eval map path

        self.eval_envs = [(name, load_stable_baselines_env(cfg_path, vector_length, mp, n_stack, number_maps,
                                                           action_frame_repeat, scaled_resolution))
                          for name, cfg_path in self.eval_cfgs]

        self.vector_length = vector_length
        self.mp = mp
        self.n_stack = n_stack

        self.eval_summary_writer = SummaryWriter(tensorboard_dir) 
Example #15
Source File: train.py    From MobileNet-V2 with Apache License 2.0 6 votes vote down vote up
def __init__(self, model, trainloader, valloader, args):
        self.model = model
        self.trainloader = trainloader
        self.valloader = valloader
        self.args = args
        self.start_epoch = 0
        self.best_top1 = 0.0

        # Loss function and Optimizer
        self.loss = None
        self.optimizer = None
        self.create_optimization()

        # Model Loading
        self.load_pretrained_model()
        self.load_checkpoint(self.args.resume_from)

        # Tensorboard Writer
        self.summary_writer = SummaryWriter(log_dir=args.summary_dir) 
Example #16
Source File: tensorboard_wrapper.py    From deepbots with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self,
                 controller,
                 log_dir="logs/results",
                 v_action=0,
                 v_observation=0,
                 v_reward=0,
                 windows=[10, 100, 200]):
        self.controller = controller

        self.step_cntr = 0
        self.step_global = 0
        self.step_reset = 0

        self.score = 0
        self.score_history = []

        self.v_action = v_action
        self.v_observation = v_observation
        self.v_reward = v_reward
        self.windows = windows

        self.file_writer = SummaryWriter(log_dir, flush_secs=30) 
Example #17
Source File: TD3_BipedalWalker-v2.py    From Deep-reinforcement-learning-with-pytorch with MIT License 6 votes vote down vote up
def __init__(self, state_dim, action_dim, max_action):

        self.actor = Actor(state_dim, action_dim, max_action).to(device)
        self.actor_target = Actor(state_dim, action_dim, max_action).to(device)
        self.critic_1 = Critic(state_dim, action_dim).to(device)
        self.critic_1_target = Critic(state_dim, action_dim).to(device)
        self.critic_2 = Critic(state_dim, action_dim).to(device)
        self.critic_2_target = Critic(state_dim, action_dim).to(device)

        self.actor_optimizer = optim.Adam(self.actor.parameters())
        self.critic_1_optimizer = optim.Adam(self.critic_1.parameters())
        self.critic_2_optimizer = optim.Adam(self.critic_2.parameters())

        self.actor_target.load_state_dict(self.actor.state_dict())
        self.critic_1_target.load_state_dict(self.critic_1.state_dict())
        self.critic_2_target.load_state_dict(self.critic_2.state_dict())

        self.max_action = max_action
        self.memory = Replay_buffer(args.capacity)
        self.writer = SummaryWriter(directory)
        self.num_critic_update_iteration = 0
        self.num_actor_update_iteration = 0
        self.num_training = 0 
Example #18
Source File: tensorboard_handlers.py    From seismic-deeplearning with MIT License 5 votes vote down vote up
def create_summary_writer(log_dir):
    writer = SummaryWriter(logdir=log_dir)
    return writer 
Example #19
Source File: logger.py    From yolov3-channel-pruning with MIT License 5 votes vote down vote up
def __init__(self, log_dir):
        """Create a summary writer logging to log_dir."""
        timestamp = datetime.fromtimestamp(time.time()).strftime('%m%d-%H:%M')
        self.writer = SummaryWriter(os.path.join(log_dir, timestamp)) 
Example #20
Source File: baseline.py    From Extremely-Fine-Grained-Entity-Typing with MIT License 5 votes vote down vote up
def __init__(self, train_log: SummaryWriter = None, validation_log: SummaryWriter = None) -> None:
    self._train_log = train_log
    self._validation_log = validation_log 
Example #21
Source File: tensorboard_logger.py    From DenseMatchingBenchmark with MIT License 5 votes vote down vote up
def before_run(self, runner):
        try:
            from tensorboardX import SummaryWriter
        except ImportError:
            raise ImportError('Please install tensorflow and tensorboardX '
                              'to use TensorboardLoggerHook.')
        else:
            if self.log_dir is None:
                self.log_dir = osp.join(runner.work_dir, 'tf_logs')
            self.writer = SummaryWriter(self.log_dir) 
Example #22
Source File: model.py    From MusicTransformer-pytorch with MIT License 5 votes vote down vote up
def generate(self,
                 prior: torch.Tensor,
                 length=2048,
                 tf_board_writer: SummaryWriter = None):
        decode_array = prior
        result_array = prior
        print(config)
        print(length)
        for i in Bar('generating').iter(range(length)):
            if decode_array.size(1) >= config.threshold_len:
                decode_array = decode_array[:, 1:]
            _, _, look_ahead_mask = \
                utils.get_masked_with_pad_tensor(decode_array.size(1), decode_array, decode_array, pad_token=config.pad_token)

            # result, _ = self.forward(decode_array, lookup_mask=look_ahead_mask)
            # result, _ = decode_fn(decode_array, look_ahead_mask)
            result, _ = self.Decoder(decode_array, None)
            result = self.fc(result)
            result = result.softmax(-1)

            if tf_board_writer:
                tf_board_writer.add_image("logits", result, global_step=i)

            u = 0
            if u > 1:
                result = result[:, -1].argmax(-1).to(decode_array.dtype)
                decode_array = torch.cat((decode_array, result.unsqueeze(-1)), -1)
            else:
                pdf = dist.OneHotCategorical(probs=result[:, -1])
                result = pdf.sample().argmax(-1).unsqueeze(-1)
                # result = torch.transpose(result, 1, 0).to(torch.int32)
                decode_array = torch.cat((decode_array, result), dim=-1)
                result_array = torch.cat((result_array, result), dim=-1)
            del look_ahead_mask
        result_array = result_array[0]
        return result_array 
Example #23
Source File: tensorboard.py    From metal with Apache License 2.0 5 votes vote down vote up
def __init__(self, log_dir=None, run_dir=None, run_name=None, **kwargs):
        super().__init__(log_dir=log_dir, run_dir=run_dir, run_name=run_name, **kwargs)

        # Set up TensorBoard summary writer
        self.tb_writer = SummaryWriter(self.log_subdir, filename_suffix=f".{run_name}") 
Example #24
Source File: worker_utils.py    From fedavgpy with MIT License 5 votes vote down vote up
def __init__(self, clients, options, name=''):
        self.options = options
        num_rounds = options['num_round'] + 1
        self.bytes_written = {c.cid: [0] * num_rounds for c in clients}
        self.client_computations = {c.cid: [0] * num_rounds for c in clients}
        self.bytes_read = {c.cid: [0] * num_rounds for c in clients}

        # Statistics in training procedure
        self.loss_on_train_data = [0] * num_rounds
        self.acc_on_train_data = [0] * num_rounds
        self.gradnorm_on_train_data = [0] * num_rounds
        self.graddiff_on_train_data = [0] * num_rounds

        # Statistics in test procedure
        self.loss_on_eval_data = [0] * num_rounds
        self.acc_on_eval_data = [0] * num_rounds

        self.result_path = mkdir(os.path.join('./result', self.options['dataset']))
        suffix = '{}_sd{}_lr{}_ep{}_bs{}_{}'.format(name,
                                                    options['seed'],
                                                    options['lr'],
                                                    options['num_epoch'],
                                                    options['batch_size'],
                                                    'w' if options['noaverage'] else 'a')

        self.exp_name = '{}_{}_{}_{}'.format(time.strftime('%Y-%m-%dT%H-%M-%S'), options['algo'],
                                             options['model'], suffix)
        if options['dis']:
            suffix = options['dis']
            self.exp_name += '_{}'.format(suffix)
        train_event_folder = mkdir(os.path.join(self.result_path, self.exp_name, 'train.event'))
        eval_event_folder = mkdir(os.path.join(self.result_path, self.exp_name, 'eval.event'))
        self.train_writer = SummaryWriter(train_event_folder)
        self.eval_writer = SummaryWriter(eval_event_folder) 
Example #25
Source File: log.py    From pase with MIT License 5 votes vote down vote up
def __init__(self, save_path, log_types=['tensorboard', 'pkl']):
        self.save_path = save_path
        if len(log_types) == 0:
            raise ValueError('Please specify at least one log_type file to '
                             'write to in the LogWriter!')
        self.writers = []
        for log_type in log_types:
            if 'tensorboard' == log_type:
                self.writers.append(SummaryWriter(save_path))
            elif 'pkl' == log_type:
                self.writers.append(PklWriter(save_path))
            else:
                raise TypeError('Unrecognized log_writer type: ', log_writer) 
Example #26
Source File: aux_model.py    From self-supervised-da with MIT License 5 votes vote down vote up
def __init__(self, args, logger):
        self.args = args
        self.logger = logger
        self.writer = SummaryWriter(args.log_dir)
        cudnn.enabled = True

        # set up model
        self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
        self.model = get_aux_net(args.network.arch)(aux_classes=args.aux_classes + 1, classes=args.n_classes)
        self.model = self.model.to(self.device)

        if args.mode == 'train':
            # set up optimizer, lr scheduler and loss functions
            optimizer = get_optimizer(self.args.training.optimizer)
            optimizer_params = {k: v for k, v in self.args.training.optimizer.items() if k != "name"}
            self.optimizer = optimizer(self.model.parameters(), **optimizer_params)
            self.scheduler = get_scheduler(self.optimizer, self.args.training.lr_scheduler)

            self.class_loss_func = nn.CrossEntropyLoss()

            self.start_iter = 0

            # resume
            if args.training.resume:
                self.load(args.model_dir + '/' + args.training.resume)

            cudnn.benchmark = True

        elif args.mode == 'val':
            self.load(os.path.join(args.model_dir, args.validation.model))
        else:
            self.load(os.path.join(args.model_dir, args.testing.model)) 
Example #27
Source File: progress_bar.py    From fairseq with MIT License 5 votes vote down vote up
def __init__(self, wrapped_bar, tensorboard_logdir):
        self.wrapped_bar = wrapped_bar
        self.tensorboard_logdir = tensorboard_logdir

        if SummaryWriter is None:
            logger.warning(
                "tensorboard not found, please install with: pip install tensorboardX"
            ) 
Example #28
Source File: logger.py    From Point-Then-Operate with Apache License 2.0 5 votes vote down vote up
def __init__(self, log_dir):
        """Initialize summary writer."""
        self.writer = SummaryWriter(log_dir) 
Example #29
Source File: trainer.py    From BigGAN-pytorch with Apache License 2.0 5 votes vote down vote up
def build_tensorboard(self):
        from tensorboardX import SummaryWriter
        # from logger import Logger
        # self.logger = Logger(self.log_path)
        
        tf_logs_path = os.path.join(self.log_path, 'tf_logs')
        self.writer = SummaryWriter(log_dir=tf_logs_path) 
Example #30
Source File: visualizer.py    From DDPAE-video-prediction with MIT License 5 votes vote down vote up
def __init__(self, tb_path):
    self.tb_path = tb_path

    if os.path.exists(tb_path):
      if prompt_yes_no('{} already exists. Proceed?'.format(tb_path)):
        os.system('rm -r {}'.format(tb_path))
      else:
        exit(0)

    self.writer = SummaryWriter(tb_path)