{"id":13578723,"url":"https://github.com/surmenok/keras_lr_finder","last_synced_at":"2026-02-05T04:08:15.509Z","repository":{"id":45751945,"uuid":"113806866","full_name":"surmenok/keras_lr_finder","owner":"surmenok","description":"Plots the change of the loss function of a Keras model when the learning rate is exponentially increasing.","archived":false,"fork":false,"pushed_at":"2025-05-27T06:34:30.000Z","size":56,"stargazers_count":258,"open_issues_count":17,"forks_count":63,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-09-23T01:57:37.448Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/surmenok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-11T03:18:18.000Z","updated_at":"2025-07-16T09:30:19.000Z","dependencies_parsed_at":"2022-08-29T15:01:20.171Z","dependency_job_id":null,"html_url":"https://github.com/surmenok/keras_lr_finder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/surmenok/keras_lr_finder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surmenok%2Fkeras_lr_finder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surmenok%2Fkeras_lr_finder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surmenok%2Fkeras_lr_finder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surmenok%2Fkeras_lr_finder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/surmenok","download_url":"https://codeload.github.com/surmenok/keras_lr_finder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surmenok%2Fkeras_lr_finder/sbom","scorecard":{"id":860221,"data":{"date":"2025-08-11","repo":{"name":"github.com/surmenok/keras_lr_finder","commit":"3bc3e83fb339c19602ff4f8aa1de318faba3853c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":6,"reason":"Found 10/15 approved changesets -- score normalized to 6","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":1,"reason":"1 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 11 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T01:02:04.649Z","repository_id":45751945,"created_at":"2025-08-24T01:02:04.649Z","updated_at":"2025-08-24T01:02:04.649Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29111003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T03:44:17.043Z","status":"ssl_error","status_checked_at":"2026-02-05T03:44:12.077Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T15:01:33.206Z","updated_at":"2026-02-05T04:08:15.504Z","avatar_url":"https://github.com/surmenok.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# keras_lr_finder\nPlots the change of the loss function of a Keras model when the learning rate is exponentially increasing.\nWill also calculate the best learning rate.\n## Purpose\nSee details in [\"Estimating an Optimal Learning Rate For a Deep Neural Network\"](https://towardsdatascience.com/estimating-optimal-learning-rate-for-a-deep-neural-network-ce32f2556ce0).\n\n## Usage\nCreate and compile a Keras model, then execute this code:\n\n```python\n# model is a Keras model\nfrom keras_lr_finder import LRFinder\nlr_finder = LRFinder(model)\n\n# Train a model with batch size 512 for 5 epochs\n# with learning rate growing exponentially from 0.0001 to 1\nlr_finder.find(x_train, y_train, start_lr=0.0001, end_lr=1, batch_size=512, epochs=5)\n```\n\n```python\n# Plot the loss, ignore 20 batches in the beginning and 5 in the end\nlr_finder.plot_loss(n_skip_beginning=20, n_skip_end=5)\n```\n\n![Loss function](https://cdn-images-1.medium.com/max/1600/1*HVj_4LWemjvOWv-cQO9y9g.png)\n\n```python\n# Plot rate of change of the loss\n# Ignore 20 batches in the beginning and 5 in the end\n# Smooth the curve using simple moving average of 20 batches\n# Limit the range for y axis to (-0.02, 0.01)\nlr_finder.plot_loss_change(sma=20, n_skip_beginning=20, n_skip_end=5, y_lim=(-0.01, 0.01))\n```\n\n![Rate of change of the loss function](https://cdn-images-1.medium.com/max/1600/1*87mKq_XomYyJE29l91K0dw.png)\n\nOnce the finder has picked your best learning rate, update your model to use it:\n```python\n# Set the learning rate of your model to the newly found one\nimport keras.backend as K\nnew_lr = lr_finder.get_best_lr(sma=4)\nmodel.optimizer.learning_rate = new_lr\n```\nYou can wrap this up nicely in a `LambdaCallback`, so that you periodically update your learning rate:\n\n```python\nfrom keras.callbacks import LambdaCallback\nfrom keras_lr_finder import LRFinder\ndef find_lr(epoch, logs):\n    # You may also make it more effective by only\n    # running this if the loss has stopped improving a la ReduceLROnPlateau\n    if epoch % 30 == 0:\n        lrf = LRFinder(model)\n        lrf.find(x_train,y_train, start_lr=0.0001, end_lr=1,batch_size=512,epochs=5)\n        new_lr = lrf.get_best_lr(4)\n        model.optimizer.learning_rate = new_lr\n    \nlcb = LambdaCallback(on_epoch_end=find_lr)\nmodel.train(callbacks=[lcb],...)\n```\n### Use With Generator\n\nThis library call also be used with generators (where `num_samples` is the total number of training samples in your training set):\n\n```python\nlrf = LRFinder(model)\nlrf.find_generator(\n    train_gen, \n    start_lr=0.0001, \n    end_lr=1, \n    epochs=5, \n    steps_per_epoch=num_samples // batch_size\n)\n```\n\n## Contributions\nContributions are welcome. Please, file issues and submit pull requests on GitHub, or contact me directly.\n\n## References\nThis code is based on:\n- The method described in section 3.3 of the 2015 paper [\"Cyclical Learning Rates for Training Neural Networks\"](https://arxiv.org/abs/1506.01186) by Leslie N. Smith\n- The implementation of the algorithm in [fastai library](https://github.com/fastai/fastai) by Jeremy Howard. See [fast.ai deep learning course](http://course.fast.ai/) for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurmenok%2Fkeras_lr_finder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsurmenok%2Fkeras_lr_finder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurmenok%2Fkeras_lr_finder/lists"}