Propagate rename of expt_dir to experiment_directory
Change num_epochs to n_epochs
Move logging.getLogger to the global scope as it isn't class-specific plus it is more standard to have it there
Change long argument lists to one-per-line so that it is easier to read
Do not convert experiment_directory to an absolute path if it isn't one as doing this has no effect on the outcome of the program
Specifying the mode in model.train(mode=True) is redundant so changed these calls to just model.train()
Reorder functions so that the higher-level ones appear earlier in the code, ie. train --> train_epochs --> train_batch
Rename train_epoches to train_epochs (typo)
Remove the default values from docstrings because 1) it is clutter 2) it is easy to see the default arguments by the method string 3) default arguments are often changed so it won't take long for the docstring to lie about the default values. They are better left out
Tools like Sentry require that logging messages look like self.logger.info("Optimizer: %s, Scheduler: %s", self.optimizer.optimizer, self.optimizer.scheduler) instead of self.logger.info("Optimizer: %s, Scheduler: %s" % (self.optimizer.optimizer, self.optimizer.scheduler)). If this weren't the case, I would change to the better .format() method
Replace NLLLoss() as a default argument with None. Mutable objects should never be set as default arguments because this causes bugs. A common beginner programming error is setting a default argument like def foo(lst=[]) instead of def foo(lst=None): if lst is None: lst = []. Here for more information
Remove unused attributes self.random_seed and self._trainer (a string name)
expt_dir
toexperiment_directory
num_epochs
ton_epochs
logging.getLogger
to the global scope as it isn't class-specific plus it is more standard to have it thereexperiment_directory
to an absolute path if it isn't one as doing this has no effect on the outcome of the programmodel.train(mode=True)
is redundant so changed these calls to justmodel.train()
train
-->train_epochs
-->train_batch
train_epoches
totrain_epochs
(typo)self.logger.info("Optimizer: %s, Scheduler: %s", self.optimizer.optimizer, self.optimizer.scheduler)
instead ofself.logger.info("Optimizer: %s, Scheduler: %s" % (self.optimizer.optimizer, self.optimizer.scheduler))
. If this weren't the case, I would change to the better.format()
methodNLLLoss()
as a default argument withNone
. Mutable objects should never be set as default arguments because this causes bugs. A common beginner programming error is setting a default argument likedef foo(lst=[])
instead ofdef foo(lst=None): if lst is None: lst = []
. Here for more informationself.random_seed
andself._trainer
(a string name)