def fit(self, n_epoch, lr=None, wd=None, cbs=None, reset_opt=False):
    with self.added_cbs(cbs):
        if (reset_opt or (not self.opt)):
            self.create_opt()
        if (wd is None):
            wd = self.wd
        if (wd is not None):
            self.opt.set_hypers(wd=wd)
        self.opt.set_hypers(lr=(self.lr if (lr is None) else lr))
        try:
            self._do_begin_fit(n_epoch)
            for epoch in range(n_epoch):
                try:
                    self.epoch = epoch
                    self('begin_epoch')
                    self._do_epoch_train()
                    self._do_epoch_validate()
                except CancelEpochException:
                    self('after_cancel_epoch')
                finally:
                    self('after_epoch')
        except CancelFitException:
            self('after_cancel_fit')
        finally:
            self('after_fit')
def fit(self, n_epoch, lr=None, wd=None, cbs=None, reset_opt=False):
    with self.added_cbs(cbs):
        if (reset_opt or (not self.opt)):
            self.create_opt()
        if (wd is None):
            wd = self.wd
        if (wd is not None):
            self.opt.set_hypers(wd=wd)
        self.opt.set_hypers(lr=(self.lr if (lr is None) else lr))
        try:
            self._do_begin_fit(n_epoch)
            for epoch in range(n_epoch):
                try:
                    self.epoch = epoch
                    self('begin_epoch')
                    self._do_epoch_train()
                    self._do_epoch_validate()
                except CancelEpochException:
                    self('after_cancel_epoch')
                finally:
                    self('after_epoch')
        except CancelFitException:
            self('after_cancel_fit')
        finally:
            self('after_fit')