Compare commits

..
8 Commits
Author SHA1 Message Date
William Falcon d6bc203f05 release v0.1.dev16 2019-05-05 12:16:52 -04:00
William Falcon 12352f1949 fixed epoch continuation from checkpoint 2019-05-05 12:15:04 -04:00
William Falcon f881bf6750 added log saving when early epoch stop 2019-04-23 11:12:01 -04:00
William Falcon 0637d8e7a5 release v0.1.dev15 2019-04-23 09:08:06 -04:00
William Falcon 2514f62913 early epoch stopping 2019-04-23 08:57:58 -04:00
William Falcon 95aee7ff96 early epoch stopping 2019-04-23 08:46:20 -04:00
William Falcon ffd6dc678c early epoch stopping 2019-04-23 08:27:27 -04:00
William Falcon 1961a6abb2 early epoch stopping 2019-04-23 08:26:48 -04:00
3 changed files with 16 additions and 7 deletions
+14 -6
View File
@@ -270,21 +270,22 @@ class Trainer(TrainerIO):
# ---------------
# RUN TRAIN STEP
# ---------------
self.__run_tng_batch(data_batch)
batch_result = self.__run_tng_batch(data_batch)
early_stop_epoch = batch_result == -1
# ---------------
# RUN VAL STEP
# ---------------
is_val_check_batch = (batch_nb + 1) % self.val_check_batch == 0
if self.fast_dev_run or is_val_check_batch:
if self.fast_dev_run or is_val_check_batch or early_stop_epoch:
self.__run_validation()
# when batch should be saved
if (batch_nb + 1) % self.log_save_interval == 0:
if (batch_nb + 1) % self.log_save_interval == 0 or early_stop_epoch:
self.experiment.save()
# when metrics should be logged
if batch_nb % self.add_log_row_interval == 0:
if batch_nb % self.add_log_row_interval == 0 or early_stop_epoch:
# count items in memory
# nb_params, nb_tensors = count_mem_items()
@@ -308,6 +309,10 @@ class Trainer(TrainerIO):
if self.__is_function_implemented('on_batch_end'):
self.model.on_batch_end()
# end epoch early
if early_stop_epoch:
break
# hook
if self.__is_function_implemented('on_epoch_end'):
self.model.on_epoch_end()
@@ -322,15 +327,16 @@ class Trainer(TrainerIO):
if stop:
return
def __run_tng_batch(self, data_batch):
if data_batch is None:
return
return 0
# hook
if self.__is_function_implemented('on_batch_start'):
response = self.model.on_batch_start(data_batch)
if response == -1:
return
return -1
if self.enable_tqdm:
self.prog_bar.update(1)
@@ -372,6 +378,8 @@ class Trainer(TrainerIO):
if self.__is_function_implemented('on_batch_end'):
self.model.on_batch_end()
return 0
def __run_validation(self):
# decide if can check epochs
can_check_epoch = (self.current_epoch + 1) % self.check_val_every_n_epoch == 0
@@ -88,6 +88,7 @@ class TrainerIO(object):
self.early_stop_callback.wait = checkpoint['early_stop_callback_wait']
self.early_stop_callback.patience = checkpoint['early_stop_callback_patience']
self.global_step = checkpoint['global_step']
self.current_epoch = checkpoint['epoch']
# restore the optimizers
optimizer_states = checkpoint['optimizer_states']
+1 -1
View File
@@ -7,7 +7,7 @@ from setuptools import setup, find_packages
# http://blog.ionelmc.ro/2014/05/25/python-packaging/
setup(
name="pytorch-lightning",
version='0.1.dev14',
version='0.1.dev16',
description="The Keras for ML researchers using PyTorch",
author="William Falcon",
author_email="waf2107@columbia.edu",