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: ```
  Plots loss as learning rate is increased.  Highest learning rate
  corresponding to a still falling loss should be chosen.
  
  If you find the LR finder is running for more epochs than you'd prefer,
  you can set max_epochs (e.g., max_epochs=5) to estimate LR with a
  smaller sample size.
  
  If lr_mult is supplied and max_epochs is None, LR will increase until loss diverges.
  Reasonable values of lr_mult are between 1.01 and 1.05.
  
  If max_epochs is supplied, lr_mult argument is ignored and computed automatically.
  
  Reference: https://arxiv.org/abs/1506.01186
  
  Args:
      start_lr (float): smallest lr to start simulation
      lr_mult (float): multiplication factor to increase LR.
                       Ignored if max_epochs is supplied.
      max_epochs (int):  maximum number of epochs to simulate.
                         lr_mult is ignored if max_epoch is supplied.
                         Default is None. Set max_epochs to an integer
                         (e.g., 5) if lr_find is taking too long
                         and running for more epochs than desired.
      class_weight(dict): class_weight parameter passed to model.fit
                          for imbalanced datasets.
      stop_factor(int): factor used to determine threhsold that loss
                        must exceed to stop training simulation.
                        Increase this if loss is erratic and lr_find
                        exits too early.
      show_plot (bool):  If True, automatically invoke lr_plot
      restore_weights_only(bool): If True, when training simulation is complete,
                                  the model weights only are restored, but not
                                  the original optimizer weights.
                                  In at least a few cases, this seems to improve performance
                                  when actual training begins. Further investigation is needed,
                                  so it is False by default.
      verbose (bool): specifies how much output to print
  Returns:
      None
  ```
docstr_tok: ["``","`","Plots","loss","as","learning","rate","is","increased",".","Highest","learning","rate","corresponding","to","a","still","falling","loss","should","be","chosen",".","If","you","find","the","LR","finder","is","running","for","more","epochs","than","you","'d","prefer",",","you","can","set","max_epochs","(","e.g.",",","max_epochs=5",")","to","estimate","LR","with","a","smaller","sample","size",".","If","lr_mult","is","supplied","and","max_epochs","is","None",",","LR","will","increase","until","loss","diverges",".","Reasonable","values","of","lr_mult","are","between","1.01","and","1.05",".","If","max_epochs","is","supplied",",","lr_mult","argument","is","ignored","and","computed","automatically",".","Reference",":","https",":","\/\/arxiv.org\/abs\/1506.01186","Args",":","start_lr","(","float",")",":","smallest","lr","to","start","simulation","lr_mult","(","float",")",":","multiplication","factor","to","increase","LR",".","Ignored","if","max_epochs","is","supplied",".","max_epochs","(","int",")",":","maximum","number","of","epochs","to","simulate",".","lr_mult","is","ignored","if","max_epoch","is","supplied",".","Default","is","None",".","Set","max_epochs","to","an","integer","(","e.g.",",","5",")","if","lr_find","is","taking","too","long","and","running","for","more","epochs","than","desired",".","class_weight","(","dict",")",":","class_weight","parameter","passed","to","model.fit","for","imbalanced","datasets",".","stop_factor","(","int",")",":","factor","used","to","determine","threhsold","that","loss","must","exceed","to","stop","training","simulation",".","Increase","this","if","loss","is","erratic","and","lr_find","exits","too","early",".","show_plot","(","bool",")",":","If","True",",","automatically","invoke","lr_plot","restore_weights_only","(","bool",")",":","If","True",",","when","training","simulation","is","complete",",","the","model","weights","only","are","restored",",","but","not","the","original","optimizer","weights",".","In","at","least","a","few","cases",",","this","seems","to","improve","performance","when","actual","training","begins",".","Further","investigation","is","needed",",","so","it","is","False","by","default",".","verbose","(","bool",")",":","specifies","how","much","output","to","print","Returns",":","None","``","`"]
code: def lr_find(
      self,
      start_lr=1e-7,
      lr_mult=1.01,
      max_epochs=None,
      class_weight=None,
      stop_factor=4,
      show_plot=False,
      suggest=False,
      restore_weights_only=False,
      verbose=1,
  ):
      """
      ```
      Plots loss as learning rate is increased.  Highest learning rate
      corresponding to a still falling loss should be chosen.
  
      If you find the LR finder is running for more epochs than you'd prefer,
      you can set max_epochs (e.g., max_epochs=5) to estimate LR with a
      smaller sample size.
  
      If lr_mult is supplied and max_epochs is None, LR will increase until loss diverges.
      Reasonable values of lr_mult are between 1.01 and 1.05.
  
      If max_epochs is supplied, lr_mult argument is ignored and computed automatically.
  
      Reference: https://arxiv.org/abs/1506.01186
  
      Args:
          start_lr (float): smallest lr to start simulation
          lr_mult (float): multiplication factor to increase LR.
                           Ignored if max_epochs is supplied.
          max_epochs (int):  maximum number of epochs to simulate.
                             lr_mult is ignored if max_epoch is supplied.
                             Default is None. Set max_epochs to an integer
                             (e.g., 5) if lr_find is taking too long
                             and running for more epochs than desired.
          class_weight(dict): class_weight parameter passed to model.fit
                              for imbalanced datasets.
          stop_factor(int): factor used to determine threhsold that loss
                            must exceed to stop training simulation.
                            Increase this if loss is erratic and lr_find
                            exits too early.
          show_plot (bool):  If True, automatically invoke lr_plot
          restore_weights_only(bool): If True, when training simulation is complete,
                                      the model weights only are restored, but not
                                      the original optimizer weights.
                                      In at least a few cases, this seems to improve performance
                                      when actual training begins. Further investigation is needed,
                                      so it is False by default.
          verbose (bool): specifies how much output to print
      Returns:
          None
      ```
      """
      # dep_fix: bug in TF 2.2 and 2.3
      if version.parse(tf.__version__) > version.parse(
          "2.1"
      ) and version.parse(tf.__version__) < version.parse("2.4"):
          if max_epochs is None:
              raise ValueError(
                  "Due to a bug in TensorFlow 2.2 and 2.3, the max_epochs argument is temporarily required. "
                  + "Please re-run with max_epochs (e.g., max_epochs=5). \n"
                  + "More info: https://github.com/tensorflow/tensorflow/issues/41174#issuecomment-656330268"
              )
  
      U.vprint(
          "simulating training for different learning rates... this may take a few moments...",
          verbose=verbose,
      )
      # save current weights and temporarily restore original weights
      # dep_fix: temporarily use save_model instead of save_weights as default due to https://github.com/tensorflow/tensorflow/issues/41116
      _weights_only = True
      if restore_weights_only:
          new_file, weightfile = tempfile.mkstemp()
          self.model.save_weights(weightfile)
      else:
          temp_folder = tempfile.mkdtemp()
          self.save_model(temp_folder)
  
      # compute steps_per_epoch
      num_samples = U.nsamples_from_data(self.train_data)
      bs = (
          self.train_data.batch_size
          if hasattr(self.train_data, "batch_size")
          else self.batch_size
      )
      if U.is_iter(self.train_data):
          use_gen = True
          steps_per_epoch = num_samples // bs
      else:
          use_gen = False
          steps_per_epoch = np.ceil(num_samples / bs)
  
      # check steps_per_epoch
      if steps_per_epoch <= 64 and max_epochs is None:
          warnings.warn(
              "max_epochs is being set to 5 since steps per epoch is small. "
              + "If you wish to estimate LR using more epochs, set max_epochs manually."
          )
          max_epochs = 5
  
      try:
          # track and plot learning rates
          self.lr_finder = LRFinder(self.model, stop_factor=stop_factor)
          self.lr_finder.find(
              self._prepare(self.train_data),
              steps_per_epoch,
              use_gen=use_gen,
              start_lr=start_lr,
              lr_mult=lr_mult,
              max_epochs=max_epochs,
              class_weight=class_weight,
              workers=self.workers,
              use_multiprocessing=self.use_multiprocessing,
              batch_size=self.batch_size,
              verbose=verbose,
          )
      except KeyboardInterrupt:
          # re-load current weights
          # self.model.load_weights(weightfile)
          self.load_model(temp_folder)
          return
  
      # re-load current weights
      # dep_fix: temporarily use load_model instead of load_weights as default due to https://github.com/tensorflow/tensorflow/issues/41116
      if restore_weights_only:
          self.model.load_weights(weightfile)
      else:
          self.load_model(temp_folder)
  
      # instructions to invoker
      U.vprint("\n", verbose=verbose)
      U.vprint("done.", verbose=verbose)
      if show_plot:
          U.vprint(
              "Visually inspect loss plot and select learning rate associated with falling loss",
              verbose=verbose,
          )
          self.lr_plot(suggest=suggest)
      else:
          U.vprint(
              "Please invoke the Learner.lr_plot() method to visually inspect "
              "the loss plot to help identify the maximal learning rate "
              "associated with falling loss.",
              verbose=verbose,
          )
      return
  
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 19 for calling the Learner obj's underlying member method code with example usage: obj.lr_find(start_lr, lr_mult, max_epochs, class_weight, stop_factor, show_plot, suggest, restore_weights_only, verbose) without return types