{"id":14958680,"url":"https://github.com/cpury/keras_gradient_noise","last_synced_at":"2025-10-24T14:32:27.536Z","repository":{"id":62573950,"uuid":"112734144","full_name":"cpury/keras_gradient_noise","owner":"cpury","description":"Add gradient noise to any Keras optimizer","archived":false,"fork":false,"pushed_at":"2020-02-17T21:04:41.000Z","size":7,"stargazers_count":37,"open_issues_count":2,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-29T23:33:52.679Z","etag":null,"topics":["deep-learning","keras","machine-learning","neural-network","neural-networks","noise","optimizer","python","tensorflow"],"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/cpury.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-01T11:48:13.000Z","updated_at":"2024-04-03T21:08:19.000Z","dependencies_parsed_at":"2022-11-03T18:47:50.099Z","dependency_job_id":null,"html_url":"https://github.com/cpury/keras_gradient_noise","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cpury%2Fkeras_gradient_noise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cpury%2Fkeras_gradient_noise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cpury%2Fkeras_gradient_noise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cpury%2Fkeras_gradient_noise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cpury","download_url":"https://codeload.github.com/cpury/keras_gradient_noise/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237990688,"owners_count":19398477,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["deep-learning","keras","machine-learning","neural-network","neural-networks","noise","optimizer","python","tensorflow"],"created_at":"2024-09-24T13:17:49.459Z","updated_at":"2025-10-24T14:32:21.487Z","avatar_url":"https://github.com/cpury.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# keras_gradient_noise\n\nSimple way to add gradient noise to any Keras / TensorFlow-Keras optimizer.\n\nInstall via: `pip install keras_gradient_noise`\n\n\n## Gradient Noise\n\nIntroduced by\n[\"Adding Gradient Noise Improves Learning for Very Deep Networks\" (Neelakantan et al 2015)](https://arxiv.org/abs/1511.06807),\nthe idea is to add a bit of decaying Gaussian noise to your gradients before\neach update step. This is shown to reduce overfitting and training loss.\n\nEquation 1 of the paper defines two parameters for the method:\n\n* η defines the total amount of noise (recommended to be one of {0.01, 0.3, 1.0})\n* γ defines the decay rate of the noise (recommended to be 0.55)\n\n\n## How to use in your code\n\nSimply wrap your optimizer class with the provided `add_gradient_noise()`\nfunction:\n\n```python\nfrom keras.optimizers import Adam\nfrom keras_gradient_noise import add_gradient_noise\n\n# ...\n\nNoisyAdam = add_gradient_noise(Adam)\n\nmodel.compile(optimizer=NoisyAdam())\n```\n\nNote the use of brackets. `add_gradient_noise()` expects a Keras-compatible\noptimizer *class*, not an *instance* of one.\n\nYou can adjust the two parameters η and γ via initialization arguments. They\nhave the following default values:\n\n```python\nNoisyOptimizer(noise_eta=0.3, noise_gamma=0.55)\n```\n\n\n## Keras vs TF.Keras\n\nThe package tries to be smart about whether to use `tf.keras` or standalone `keras`.\nIf you get an error in your case, try passing a specific Keras-module to the\n`add_gradient_noise` function. E.g.\n\n```\nimport keras\n\n...\n\nadd_gradient_noise(MyOptim, keras=keras)\n```\n\n\n## Feedback, contributions, etc.\n\nPlease don't hesitate to reach out via GitHub issues or a quick email! Thanks!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcpury%2Fkeras_gradient_noise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcpury%2Fkeras_gradient_noise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcpury%2Fkeras_gradient_noise/lists"}