captain-pool / GSOC

Repository for Google Summer of Code 2019 https://summerofcode.withgoogle.com/projects/#4662790671826944
MIT License
68 stars 22 forks source link

Merged phase_1 and phase_2 into train.py #32

Closed captain-pool closed 5 years ago

captain-pool commented 5 years ago

Addresses Issue: #30 Merged Phase 1 and Phase 2 trainer. Tn this PR the two functions from those different files(phase_1.py and phase_2.py) are merged into one file called train.py. Since these are two independent functions, some of the same variables are being reused and reloaded in each of the cases, which is not one of the finest solution, provided it may take some time, onloading and offloading the dataset from the memory.

Proposed Design Suggestion

Instead of using different functions and using similar variables in two different functions, It would be better to use this design, saving memory and time wasted in on loading and off loading data, (especially, reloading the entire dataset) to and from the memory.

class Trainer(object):
  @classmethod
  def setup_training(cls, Generator, Discriminator, summary_writer, data_dir=None):
    cls.G = Generator
    cls.D = Discriminator
    cls.summary_writer = summary_writer
    cls.dataset = utils.load_dataset(data_dir=data_dir, ...)
  @classmethod
  def train_psnr(cls):
    # use class params:
    # cls.G, cls.D, cls.summary_writer, cls.dataset
    # to train the psnr model
    pass
  @classmethod
  def train_gan(cls):
    # use class params:
    # cls.G, cls.D, cls.summary_writer, cls.dataset
    # to train ESRGAN model
    pass

@srjoglekar246 what do you think?

captain-pool commented 5 years ago

After this gets merged, I will add distribution strategy in a new PR. Thus addressing Issue #29