Skip to content

Commit

Permalink
fix various pylint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AdeelH committed Nov 8, 2023
1 parent 3ffcdbc commit f11e17a
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,20 @@ def __init__(self,
self.valid_ds = valid_ds
self.test_ds = test_ds

self.train_dl = None
self.valid_dl = None
self.test_dl = None

self.model = model
self.loss = loss
self.opt = optimizer
self.epoch_scheduler = epoch_scheduler
self.step_scheduler = step_scheduler

self.tb_process = None
self.tb_writer = None
self.tb_log_dir = None

# ---------------------------
# Set URIs
# ---------------------------
Expand Down Expand Up @@ -552,8 +560,8 @@ def overfit(self):
self.opt.step()

if (step + 1) % 25 == 0:
log.info('\nstep: {}'.format(step))
log.info('train_loss: {}'.format(loss))
log.info('\nstep: %d', step)
log.info('train_loss: %f', loss)

torch.save(self.model.state_dict(), self.last_model_weights_path)

Expand Down Expand Up @@ -1261,12 +1269,11 @@ def get_dataloader(self, split: str) -> DataLoader:
"""
if split == 'train':
return self.train_dl
elif split == 'valid':
if split == 'valid':
return self.valid_dl
elif split == 'test':
if split == 'test':
return self.test_dl
else:
raise ValueError('{} is not a valid split'.format(split))
raise ValueError(f'{split} is not a valid split')

def normalize_input(self, x: np.ndarray) -> np.ndarray:
"""Normalize x to [0, 1].
Expand Down Expand Up @@ -1360,10 +1367,8 @@ def run_tensorboard(self):
"""Run TB server serving logged stats."""
if self.cfg.run_tensorboard:
log.info('Starting tensorboard process')
self.tb_process = Popen([
'tensorboard', '--bind_all',
'--logdir={}'.format(self.tb_log_dir)
])
self.tb_process = Popen(
['tensorboard', '--bind_all', f'--logdir={self.tb_log_dir}'])
terminate_at_exit(self.tb_process)

def stop_tensorboard(self):
Expand Down

0 comments on commit f11e17a

Please sign in to comment.