class_docstr: ```
  Abstract class used to tune and train Keras models. The fit method is
  an abstract method and must be implemented by subclasses.
  ```
class_docstr_tok: ["``","`","Abstract","class","used","to","tune","and","train","Keras","models",".","The","fit","method","is","an","abstract","method","and","must","be","implemented","by","subclasses",".","``","`"]
docstr: ```
  Automatically train model using a default learning rate schedule shown to work well
  in practice.  By default, this method currently employs a triangular learning
  rate policy (https://arxiv.org/abs/1506.01186).
  During each epoch, this learning rate policy varies the learning rate from lr/10 to lr
  and then back to a low learning rate that is near-zero.
  If epochs is None, then early_stopping and reduce_on_plateau are atomatically
  set to 5 and 2, respectively.
  
  Args:
      lr (float): optional initial learning rate.  If missing,
                 lr will be estimated automatically.
                 It is recommended that you estimate lr yourself by
                 running lr_finder (and lr_plot) and visually inspect plot
                 for dramatic loss drop.
      epochs (int): Number of epochs.  If None, training will continue until
                    validation loss no longer improves after 5 epochs.
      early_stopping (int):     If not None, training will automatically stop after this many
                                epochs of no improvement in validation loss.
                                Upon completion, model will be loaded with weights from epoch
                                with lowest validation loss.
                                NOTE: If reduce_on_plateau is also enabled, then
                                early_stopping must be greater than reduce_on_plateau.
                                Example: early_stopping=6, reduce_on_plateau=3.
      reduce_on_plateau (int):  If not None, will lower learning rate when
                                when validation loss fails to improve after
                                the specified number of epochs.
                                NOTE: If early_stopping is enabled, then
                                reduce_on_plateu must be less than early_stopping.
                                Example: early_stopping=6, reduce_on_plateau=3.
      reduce_factor (int):      Learning reate is reduced by this factor on plateau.
                                Only takes effect if reduce_on_plateau > 0.
      cycle_momentum (bool):    If True and optimizer is Adam, Nadam, or Adamax, momentum of
                                optimzer will be cycled between 0.95 and 0.85 as described in
                                https://arxiv.org/abs/1803.09820.
                                Only takes effect if Adam, Nadam, or Adamax optimizer is used.
      max_momentum(float):  maximum momentum to use when cycle_momentum=True
      min_momentum(float): minimum momentum to use when cycle_momentum=True
      checkpoint_folder (string): Folder path in which to save the model weights
                                  for each epoch.
                                  File name will be of the form:
                                  weights-{epoch:02d}-{val_loss:.2f}.hdf5
      monitor (str):              what metric to monitor for early_stopping
                                  and reduce_on_plateau. Defaults to 'val_loss'.
                                  Only used if early_stopping or reduce_on_plateau
                                  is enabled.
      class_weight (dict):       Optional dictionary mapping class indices (integers) to a weight (float)
      callbacks (list): list of Callback instances to employ during training
      steps_per_epoch(int):    Steps per epoch. If None, then, math.ceil(num_samples/batch_size) is used.
                               Ignored unless training dataset is generator.
      verbose (bool):  verbose mode
  ```
docstr_tok: ["``","`","Automatically","train","model","using","a","default","learning","rate","schedule","shown","to","work","well","in","practice",".","By","default",",","this","method","currently","employs","a","triangular","learning","rate","policy","(","https",":","\/\/arxiv.org\/abs\/1506.01186",")",".","During","each","epoch",",","this","learning","rate","policy","varies","the","learning","rate","from","lr\/10","to","lr","and","then","back","to","a","low","learning","rate","that","is","near-zero",".","If","epochs","is","None",",","then","early_stopping","and","reduce_on_plateau","are","atomatically","set","to","5","and","2",",","respectively",".","Args",":","lr","(","float",")",":","optional","initial","learning","rate",".","If","missing",",","lr","will","be","estimated","automatically",".","It","is","recommended","that","you","estimate","lr","yourself","by","running","lr_finder","(","and","lr_plot",")","and","visually","inspect","plot","for","dramatic","loss","drop",".","epochs","(","int",")",":","Number","of","epochs",".","If","None",",","training","will","continue","until","validation","loss","no","longer","improves","after","5","epochs",".","early_stopping","(","int",")",":","If","not","None",",","training","will","automatically","stop","after","this","many","epochs","of","no","improvement","in","validation","loss",".","Upon","completion",",","model","will","be","loaded","with","weights","from","epoch","with","lowest","validation","loss",".","NOTE",":","If","reduce_on_plateau","is","also","enabled",",","then","early_stopping","must","be","greater","than","reduce_on_plateau",".","Example",":","early_stopping=6",",","reduce_on_plateau=3",".","reduce_on_plateau","(","int",")",":","If","not","None",",","will","lower","learning","rate","when","when","validation","loss","fails","to","improve","after","the","specified","number","of","epochs",".","NOTE",":","If","early_stopping","is","enabled",",","then","reduce_on_plateu","must","be","less","than","early_stopping",".","Example",":","early_stopping=6",",","reduce_on_plateau=3",".","reduce_factor","(","int",")",":","Learning","reate","is","reduced","by","this","factor","on","plateau",".","Only","takes","effect","if","reduce_on_plateau",">","0.","cycle_momentum","(","bool",")",":","If","True","and","optimizer","is","Adam",",","Nadam",",","or","Adamax",",","momentum","of","optimzer","will","be","cycled","between","0.95","and","0.85","as","described","in","https",":","\/\/arxiv.org\/abs\/1803.09820",".","Only","takes","effect","if","Adam",",","Nadam",",","or","Adamax","optimizer","is","used",".","max_momentum","(","float",")",":","maximum","momentum","to","use","when","cycle_momentum=True","min_momentum","(","float",")",":","minimum","momentum","to","use","when","cycle_momentum=True","checkpoint_folder","(","string",")",":","Folder","path","in","which","to","save","the","model","weights","for","each","epoch",".","File","name","will","be","of","the","form",":","weights-","{","epoch:02d","}","-","{","val_loss",":",".2f","}",".hdf5","monitor","(","str",")",":","what","metric","to","monitor","for","early_stopping","and","reduce_on_plateau",".","Defaults","to","'val_loss","'",".","Only","used","if","early_stopping","or","reduce_on_plateau","is","enabled",".","class_weight","(","dict",")",":","Optional","dictionary","mapping","class","indices","(","integers",")","to","a","weight","(","float",")","callbacks","(","list",")",":","list","of","Callback","instances","to","employ","during","training","steps_per_epoch","(","int",")",":","Steps","per","epoch",".","If","None",",","then",",","math.ceil","(","num_samples\/batch_size",")","is","used",".","Ignored","unless","training","dataset","is","generator",".","verbose","(","bool",")",":","verbose","mode","``","`"]
code: def autofit(
      self,
      lr,
      epochs=None,
      early_stopping=None,
      reduce_on_plateau=None,
      reduce_factor=2,
      cycle_momentum=True,
      max_momentum=0.95,
      min_momentum=0.85,
      monitor="val_loss",
      checkpoint_folder=None,
      class_weight=None,
      callbacks=[],
      steps_per_epoch=None,
      verbose=1,
  ):
      """
      ```
      Automatically train model using a default learning rate schedule shown to work well
      in practice.  By default, this method currently employs a triangular learning
      rate policy (https://arxiv.org/abs/1506.01186).
      During each epoch, this learning rate policy varies the learning rate from lr/10 to lr
      and then back to a low learning rate that is near-zero.
      If epochs is None, then early_stopping and reduce_on_plateau are atomatically
      set to 5 and 2, respectively.
  
      Args:
          lr (float): optional initial learning rate.  If missing,
                     lr will be estimated automatically.
                     It is recommended that you estimate lr yourself by
                     running lr_finder (and lr_plot) and visually inspect plot
                     for dramatic loss drop.
          epochs (int): Number of epochs.  If None, training will continue until
                        validation loss no longer improves after 5 epochs.
          early_stopping (int):     If not None, training will automatically stop after this many
                                    epochs of no improvement in validation loss.
                                    Upon completion, model will be loaded with weights from epoch
                                    with lowest validation loss.
                                    NOTE: If reduce_on_plateau is also enabled, then
                                    early_stopping must be greater than reduce_on_plateau.
                                    Example: early_stopping=6, reduce_on_plateau=3.
          reduce_on_plateau (int):  If not None, will lower learning rate when
                                    when validation loss fails to improve after
                                    the specified number of epochs.
                                    NOTE: If early_stopping is enabled, then
                                    reduce_on_plateu must be less than early_stopping.
                                    Example: early_stopping=6, reduce_on_plateau=3.
          reduce_factor (int):      Learning reate is reduced by this factor on plateau.
                                    Only takes effect if reduce_on_plateau > 0.
          cycle_momentum (bool):    If True and optimizer is Adam, Nadam, or Adamax, momentum of
                                    optimzer will be cycled between 0.95 and 0.85 as described in
                                    https://arxiv.org/abs/1803.09820.
                                    Only takes effect if Adam, Nadam, or Adamax optimizer is used.
          max_momentum(float):  maximum momentum to use when cycle_momentum=True
          min_momentum(float): minimum momentum to use when cycle_momentum=True
          checkpoint_folder (string): Folder path in which to save the model weights
                                      for each epoch.
                                      File name will be of the form:
                                      weights-{epoch:02d}-{val_loss:.2f}.hdf5
          monitor (str):              what metric to monitor for early_stopping
                                      and reduce_on_plateau. Defaults to 'val_loss'.
                                      Only used if early_stopping or reduce_on_plateau
                                      is enabled.
          class_weight (dict):       Optional dictionary mapping class indices (integers) to a weight (float)
          callbacks (list): list of Callback instances to employ during training
          steps_per_epoch(int):    Steps per epoch. If None, then, math.ceil(num_samples/batch_size) is used.
                                   Ignored unless training dataset is generator.
          verbose (bool):  verbose mode
      ```
      """
      # check optimizer
      if not self._is_adamlike() and cycle_momentum:
          warnings.warn(
              "cyclical momentum has been disabled because "
              + 'optimizer is not "Adam-like" with beta_1 param'
          )
          cycle_momentum = False
  
      # setup learning rate policy
      num_samples = U.nsamples_from_data(self.train_data)
      if steps_per_epoch is None:
          steps_per_epoch = math.ceil(num_samples / self.batch_size)
      step_size = math.ceil(steps_per_epoch / 2)
  
      # handle missing epochs
      if epochs is None:
          epochs = 1024
          if not early_stopping:
              early_stopping = U.DEFAULT_ES
              U.vprint(
                  "early_stopping automatically enabled at patience=%s"
                  % (U.DEFAULT_ES),
                  verbose=verbose,
              )
          if not reduce_on_plateau:
              reduce_on_plateau = U.DEFAULT_ROP
              U.vprint(
                  "reduce_on_plateau automatically enabled at patience=%s"
                  % (U.DEFAULT_ROP),
                  verbose=verbose,
              )
      if (
          reduce_on_plateau
          and early_stopping
          and (reduce_on_plateau > early_stopping)
      ):
          warnings.warn(
              "reduce_on_plateau=%s and is greater than "
              % (reduce_on_plateau)
              + "early_stopping=%s.  " % (early_stopping)
              + "Either reduce reduce_on_plateau or set early_stopping "
              + "to be higher."
          )
  
      # check monitor
      if reduce_on_plateau is not None or early_stopping is not None:
          if monitor.startswith("val_") and self.val_data is None:
              raise ValueError(
                  "monitor is %s but no val_data was supplied.\nChange monitor or supply val_data to get_learner function."
                  % monitor
              )
          if (
              monitor != "val_loss"
              and monitor not in self._monitor_metrics
          ):
              raise ValueError(
                  "monitor must be one of {%s}"
                  % (self._monitor_metrics)
              )
  
      # setup callbacks for learning rates and early stopping
      if not callbacks:
          kcallbacks = []
      else:
          kcallbacks = callbacks[:]
      if cycle_momentum:
          max_momentum = max_momentum
          min_momentum = min_momentum
      else:
          max_momentum = None
          min_momentum = None
  
      from .lroptimize.triangular import CyclicLR
  
      clr = CyclicLR(
          base_lr=lr / 10,
          max_lr=lr,
          step_size=step_size,
          verbose=verbose,
          monitor=monitor,
          reduce_on_plateau=reduce_on_plateau,
          reduce_factor=reduce_factor,
          max_momentum=max_momentum,
          min_momentum=min_momentum,
      )
      kcallbacks.append(clr)
      if early_stopping:
          kcallbacks.append(
              keras.callbacks.EarlyStopping(
                  monitor=monitor,
                  min_delta=0,
                  patience=early_stopping,
                  restore_best_weights=True,
                  verbose=1,
                  mode="auto",
              )
          )
  
      # start training
      U.vprint("\n", verbose=verbose)
      policy = "triangular learning rate"
      U.vprint(
          "begin training using %s policy with max lr of %s..."
          % (policy, lr),
          verbose=verbose,
      )
      hist = self.fit(
          lr,
          epochs,
          early_stopping=early_stopping,
          checkpoint_folder=checkpoint_folder,
          verbose=verbose,
          class_weight=class_weight,
          callbacks=kcallbacks,
          steps_per_epoch=steps_per_epoch,
      )
      hist.history["lr"] = clr.history["lr"]
      hist.history["iterations"] = clr.history["iterations"]
      if cycle_momentum:
          hist.history["momentum"] = clr.history["momentum"]
      self.history = hist
      return hist
  
imports: from .None import utils
  from .graph.predictor import LinkPredictor, NodePredictor
  from .graph.preprocessor import LinkPreprocessor, NodePreprocessor
  from .imports import *
  from .lroptimize.lrfinder import *
  from .tabular.predictor import TabularPredictor
  from .tabular.preprocessor import TabularPreprocessor
  from .text.ner.predictor import NERPredictor
  from .text.ner.preprocessor import NERPreprocessor
  from .text.predictor import TextPredictor
  from .text.preprocessor import BERTPreprocessor, TextPreprocessor, TransformersPreprocessor
  from .vision.predictor import ImagePredictor
  from .vision.preprocessor import ImagePreprocessor
label_desc: Use image node_id 33 for calling the Learner obj's underlying member method code with example usage: obj.autofit(lr, epochs, early_stopping, reduce_on_plateau, reduce_factor, cycle_momentum, max_momentum, min_momentum, monitor, checkpoint_folder, class_weight, callbacks, steps_per_epoch, verbose) and returns: hist