class_docstr: ```
  Main class used to tune and train Keras models
  using Array data.  An objects of this class should be instantiated
  via the ktrain.get_learner method instead of directly.
  Main parameters are:
  
  
  model (Model):        A compiled instance of keras.engine.training.Model
  train_data (ndarray): A tuple of (x_train, y_train), where x_train and
                        y_train are numpy.ndarrays.
  val_data (ndarray):   A tuple of (x_test, y_test), where x_test and
                        y_test are numpy.ndarrays.
  ```
class_docstr_tok: ["``","`","Main","class","used","to","tune","and","train","Keras","models","using","Array","data",".","An","objects","of","this","class","should","be","instantiated","via","the","ktrain.get_learner","method","instead","of","directly",".","Main","parameters","are",":","model","(","Model",")",":","A","compiled","instance","of","keras.engine.training.Model","train_data","(","ndarray",")",":","A","tuple","of","(","x_train",",","y_train",")",",","where","x_train","and","y_train","are","numpy.ndarrays",".","val_data","(","ndarray",")",":","A","tuple","of","(","x_test",",","y_test",")",",","where","x_test","and","y_test","are","numpy.ndarrays",".","``","`"]
docstr: ```
  Trains the model. By default, fit is simply a wrapper for model.fit.
  When cycle_len parameter is supplied, an SGDR learning rate schedule is used.
  Trains the model.
  
  lr (float): learning rate
  n_cycles (int):  n_cycles
  cycle_len (int): If not None, decay learning rate over <cycle_len>
                   epochs until restarting/resetting learning rate to <lr>.
                   If None, lr remains constant
  cycle_mult (int): Increase cycle_len by factor of cycle_mult.
                    This will gradually elongate the cycle.
                    Has no effect if cycle_len is None.
  lr_decay(float): rate of decay of learning rate each cycle
  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
  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.
  callbacks (list):         list of Callback instances to employ during training
  class_weight (dict):       Optional dictionary mapping class indices (integers) to a weight (float)
  steps_per_epoch(int):    Steps per epoch. If None, then, math.ceil(num_samples/batch_size) is used.
                           Ignored unless training dataset is generator (and in ArrayLearner instances).
  verbose (bool):           whether or not to show progress bar
  ```
docstr_tok: ["``","`","Trains","the","model",".","By","default",",","fit","is","simply","a","wrapper","for","model.fit",".","When","cycle_len","parameter","is","supplied",",","an","SGDR","learning","rate","schedule","is","used",".","Trains","the","model",".","lr","(","float",")",":","learning","rate","n_cycles","(","int",")",":","n_cycles","cycle_len","(","int",")",":","If","not","None",",","decay","learning","rate","over","<","cycle_len",">","epochs","until","restarting\/resetting","learning","rate","to","<","lr",">",".","If","None",",","lr","remains","constant","cycle_mult","(","int",")",":","Increase","cycle_len","by","factor","of","cycle_mult",".","This","will","gradually","elongate","the","cycle",".","Has","no","effect","if","cycle_len","is","None",".","lr_decay","(","float",")",":","rate","of","decay","of","learning","rate","each","cycle","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","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",".","callbacks","(","list",")",":","list","of","Callback","instances","to","employ","during","training","class_weight","(","dict",")",":","Optional","dictionary","mapping","class","indices","(","integers",")","to","a","weight","(","float",")","steps_per_epoch","(","int",")",":","Steps","per","epoch",".","If","None",",","then",",","math.ceil","(","num_samples\/batch_size",")","is","used",".","Ignored","unless","training","dataset","is","generator","(","and","in","ArrayLearner","instances",")",".","verbose","(","bool",")",":","whether","or","not","to","show","progress","bar","``","`"]
code: def fit(
      self,
      lr,
      n_cycles,
      cycle_len=None,
      cycle_mult=1,
      lr_decay=1,
      checkpoint_folder=None,
      early_stopping=None,
      verbose=1,
      class_weight=None,
      callbacks=[],
      steps_per_epoch=None,
  ):
      """
      ```
      Trains the model. By default, fit is simply a wrapper for model.fit.
      When cycle_len parameter is supplied, an SGDR learning rate schedule is used.
      Trains the model.
  
      lr (float): learning rate
      n_cycles (int):  n_cycles
      cycle_len (int): If not None, decay learning rate over <cycle_len>
                       epochs until restarting/resetting learning rate to <lr>.
                       If None, lr remains constant
      cycle_mult (int): Increase cycle_len by factor of cycle_mult.
                        This will gradually elongate the cycle.
                        Has no effect if cycle_len is None.
      lr_decay(float): rate of decay of learning rate each cycle
      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
      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.
      callbacks (list):         list of Callback instances to employ during training
      class_weight (dict):       Optional dictionary mapping class indices (integers) to a weight (float)
      steps_per_epoch(int):    Steps per epoch. If None, then, math.ceil(num_samples/batch_size) is used.
                               Ignored unless training dataset is generator (and in ArrayLearner instances).
      verbose (bool):           whether or not to show progress bar
      ```
      """
  
      # check early_stopping
      if self.val_data is None and early_stopping is not None:
          raise ValueError(
              "early_stopping monitors val_loss but validation data not set"
          )
  
      # setup data
      x_train = self.train_data[0]
      y_train = self.train_data[1]
      validation = None
      if self.val_data:
          validation = (self.val_data[0], self.val_data[1])
      # setup learning rate schedule
      epochs = self._check_cycles(n_cycles, cycle_len, cycle_mult)
      self.set_lr(lr)
  
      # set call backs
      kcallbacks = callbacks if callbacks else None
      kcallbacks = self._cb_sgdr(
          lr,
          np.ceil(len(x_train) / self.batch_size),
          cycle_len,
          cycle_mult,
          lr_decay,
          callbacks=kcallbacks,
      )
      kcallbacks = self._cb_checkpoint(
          checkpoint_folder, callbacks=kcallbacks
      )
      kcallbacks = self._cb_earlystopping(
          early_stopping, callbacks=kcallbacks
      )
      sgdr = (
          [
              cb
              for cb in kcallbacks
              if type(cb).__name__ == "SGDRScheduler"
          ]
          if kcallbacks
          else None
      )
      sgdr = sgdr[0] if sgdr else None
  
      # train model
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore", message=".*Check your callbacks.*"
          )
          hist = self.model.fit(
              self._prepare(x_train),
              self._prepare(y_train, train=False),
              batch_size=self.batch_size,
              epochs=epochs,
              validation_data=validation,
              verbose=verbose,
              shuffle=True,
              class_weight=class_weight,
              callbacks=kcallbacks,
          )
  
      if sgdr is not None:
          hist.history["lr"] = sgdr.history["lr"]
      self.history = hist
  
      if early_stopping:
          U.vprint(
              "Weights from best epoch have been loaded into model.",
              verbose=verbose,
          )
          # loss, acc = self.model.evaluate(self.val_data[0], self.val_data[1])
          # U.vprint('\n', verbose=verbose)
          # U.vprint('Early stopping due to no further improvement.', verbose=verbose)
          # U.vprint('final loss:%s, final score:%s' % (loss, acc), verbose=verbose)
  
      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 2 for calling the ArrayLearner obj's underlying member method code with example usage: obj.fit(lr, n_cycles, cycle_len, cycle_mult, lr_decay, checkpoint_folder, early_stopping, verbose, class_weight, callbacks, steps_per_epoch) and returns: hist