{"id":18249344,"url":"https://github.com/debugger404/earlystoping-torch-keras","last_synced_at":"2026-04-05T23:33:59.115Z","repository":{"id":182817186,"uuid":"367275702","full_name":"deBUGger404/Earlystoping-torch-keras","owner":"deBUGger404","description":"PyTorch and TensorFlow-Keras Training - 🧠🛠️ Utilizes CIFAR-10 dataset for PyTorch and MNIST for TensorFlow-Keras. Implements early-stopping to prevent overfitting during training. Provides code snippets for early-stopping implementation in both PyTorch and TensorFlow-Keras.","archived":false,"fork":false,"pushed_at":"2021-05-14T15:09:01.000Z","size":314,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-03T19:30:37.652Z","etag":null,"topics":["cifar10","early-stopping","image-classification","keras","mnist-classification","python","pytorch","tensorflow","training"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/deBUGger404.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,"governance":null}},"created_at":"2021-05-14T06:53:03.000Z","updated_at":"2024-04-10T04:36:06.000Z","dependencies_parsed_at":"2023-07-21T16:27:07.526Z","dependency_job_id":null,"html_url":"https://github.com/deBUGger404/Earlystoping-torch-keras","commit_stats":null,"previous_names":["debugger404/earlystoping-torch-keras"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/deBUGger404/Earlystoping-torch-keras","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deBUGger404%2FEarlystoping-torch-keras","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deBUGger404%2FEarlystoping-torch-keras/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deBUGger404%2FEarlystoping-torch-keras/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deBUGger404%2FEarlystoping-torch-keras/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deBUGger404","download_url":"https://codeload.github.com/deBUGger404/Earlystoping-torch-keras/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deBUGger404%2FEarlystoping-torch-keras/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31454199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"ssl_error","status_checked_at":"2026-04-05T21:22:51.943Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["cifar10","early-stopping","image-classification","keras","mnist-classification","python","pytorch","tensorflow","training"],"created_at":"2024-11-05T09:39:48.358Z","updated_at":"2026-04-05T23:33:59.094Z","avatar_url":"https://github.com/deBUGger404.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Earlystoping Torch/Tensorflow-Keras\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/59862546/117540979-59b64100-b02f-11eb-9ea9-457ecf2e2271.png\" width=\"400\" height=\"200\"\u003e \n\u003cimg src=\"https://blog.keras.io/img/keras-tensorflow-logo.jpg\" width=\"400\" height=\"200\"\u003e \n\u003cp\u003e\n  \n  \n## Contents\n- [Introduction](#introduction)\n- [Prerequisites](#prerequisites)\n- [Training](#training)\n  - [Pytorch](#pytorch)\n  - [Tensorflow-Keras](#tensorflow-keras)\n- [Python-Script](#python-script)\n\n## Introduction\n- In PyTorch training, I used the `CIFAR-10` dataset which consists of 60000 32x32 colour images in 10 classes, with 6000 images per class. There are 50000 training images and 10000 test images.\n- In TensorFlow-Keras training, I used MNIST data which consists of 60,000 28x28 grayscale images of the 10 digits, along with a test set of 10,000 images.\n\n## Prerequisites\n- Python\u003e=3.6\n- PyTorch \u003e=1.4\n- Tensorflow\u003e=2.0\n- Library are mentioned in `requirenments.txt`\n\n## Training\n- If We train our model with too many epochs then it will start overfitting on the training dataset and showing worse performance on the test dataset. And vice versa, too few epochs can lead the model to underfit on trainset.\n- So, Early-stopping is an approach to stop training after some epoch if there is no significant improvement in performance.\n- Basically, Early-stopping monitors the performance during the training using TensorFlow-Keras API.\n  ### Pytorch:\n  Below codes, use for early-stopping in PyTorch to overcome the model overfitting.\n    ```python\n    #use the ./pytorch/utils.py\n    #as you can see the below code which will monitor the performance during the training\n        elif score \u003c self.best_score + self.delta:\n          self.counter += 1\n          self.trace_func(f'EarlyStopping counter: {self.counter} out of {self.patience}')\n          if self.counter \u003e= self.patience:\n              self.early_stop = True\n    # below code save model checkpoint while model will not imporving anymore\n        def save_checkpoint(self, val_loss, model):\n          if self.verbose:\n              self.trace_func(f'Validation loss decreased ({self.val_loss_min:.6f} --\u003e {val_loss:.6f}).  Saving model ...')\n          torch.save(model, self.path)\n          self.val_loss_min = val_loss\n    ```\n   ### Tensorflow-Keras\n    Below code, use for early-stoping for better performance in Keras.\n    ```python\n    import tensorflow as tf\n    es = tf.keras.callbacks.EarlyStopping( monitor=\"val_loss\", patience=2, verbose=1, restore_best_weights=True)\n    ```\n\n ## Python-Script\n ```python\n  # Start training with: \n  # pytorch\n  python earlystoping_pytorch.py\n\n  #tensorflow-keras\n  python keras_early_stoping.py\n ```\n # Give a :star: to this Repository!\n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebugger404%2Fearlystoping-torch-keras","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdebugger404%2Fearlystoping-torch-keras","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebugger404%2Fearlystoping-torch-keras/lists"}