class_docstr: ```
  Tracks (and plots) the change in loss of a Keras model as learning rate is gradually increased.
  Used to visually identify a good learning rate, given model and data.
  Reference:
      Original Paper: https://arxiv.org/abs/1506.01186
  ```
class_docstr_tok: ["``","`","Tracks","(","and","plots",")","the","change","in","loss","of","a","Keras","model","as","learning","rate","is","gradually","increased",".","Used","to","visually","identify","a","good","learning","rate",",","given","model","and","data",".","Reference",":","Original","Paper",":","https",":","\/\/arxiv.org\/abs\/1506.01186","``","`"]
docstr: valley method for LR suggestions:
  https://github.com/fastai/fastai/pull/3377
docstr_tok: ["valley","method","for","LR","suggestions",":","https",":","\/\/github.com\/fastai\/fastai\/pull\/3377"]
code: def valley(self, lrs, losses):
      """
      valley method for LR suggestions:
      https://github.com/fastai/fastai/pull/3377
      """
      n = len(losses)
      max_start, max_end = 0, 0
  
      # find the longest valley
      lds = [1] * n
      for i in range(1, n):
          for j in range(0, i):
              if (losses[i] < losses[j]) and (lds[i] < lds[j] + 1):
                  lds[i] = lds[j] + 1
              if lds[max_end] < lds[i]:
                  max_end = i
                  max_start = max_end - lds[max_end]
  
      sections = (max_end - max_start) / 3
      idx = max_start + int(sections) + int(sections / 2)
  
      # return lrs[idx], (lrs[idx], losses[idx])
      return idx
  
file_path: ktrain/ktrain/lroptimize/lrfinder.py
imports: from ..None import utils
  from ..imports import *
label_desc: Use image node_id 5 for calling the LRFinder obj's underlying member method code with example usage: obj.valley(lrs, losses) and returns: idx