{"id":13716996,"url":"https://github.com/henryre/pytorch-fitmodule","last_synced_at":"2025-05-07T06:31:48.535Z","repository":{"id":145431943,"uuid":"99150962","full_name":"henryre/pytorch-fitmodule","owner":"henryre","description":"Super simple fit method for PyTorch Modules","archived":true,"fork":false,"pushed_at":"2020-06-24T16:31:00.000Z","size":10,"stargazers_count":98,"open_issues_count":3,"forks_count":18,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-14T05:33:46.275Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/henryre.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-02T18:56:03.000Z","updated_at":"2024-10-17T01:27:37.000Z","dependencies_parsed_at":"2023-06-03T18:15:14.709Z","dependency_job_id":null,"html_url":"https://github.com/henryre/pytorch-fitmodule","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryre%2Fpytorch-fitmodule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryre%2Fpytorch-fitmodule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryre%2Fpytorch-fitmodule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryre%2Fpytorch-fitmodule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/henryre","download_url":"https://codeload.github.com/henryre/pytorch-fitmodule/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252826890,"owners_count":21810200,"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":[],"created_at":"2024-08-03T00:01:16.548Z","updated_at":"2025-05-07T06:31:48.529Z","avatar_url":"https://github.com/henryre.png","language":"Python","funding_links":[],"categories":["Pytorch \u0026 related libraries｜Pytorch \u0026 相关库","Pytorch \u0026 related libraries"],"sub_categories":["Other libraries｜其他库:","Other libraries:"],"readme":"# A super simple `fit` method for PyTorch `Module`s\n\nEver wanted a pretty, Keras-like `fit` method for your PyTorch `Module`s?\nHere's one. It lacks some of the advanced functionality, but it's easy to use:\n\n```python\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom pytorch_fitmodule import FitModule\n\nX, Y, n_classes = torch.get_me_some_data()\n\nclass MLP(FitModule):\n    def __init__(self, n_feats, n_classes, hidden_size=50):\n        super(MLP, self).__init__()\n        self.fc1 = nn.Linear(n_feats, hidden_size)\n        self.fc2 = nn.Linear(hidden_size, n_classes)\n    def forward(self, x):\n        return F.log_softmax(self.fc2(F.relu(self.fc1(x))))\n\nf = MLP(X.size()[1], n_classes)\n\ndef n_correct(y_true, y_pred):\n    return (y_true == torch.max(y_pred, 1)[1]).sum()\n\nf.fit(X, Y, epochs=5, validation_split=0.3, metrics=[n_correct])\n```\n\n\n## Installation\n\nJust clone this repo and add it to your Python path. You'll need\n* [PyTorch](http://pytorch.org)\n* [NumPy](http://numpy.org/)\n* [Scikit-Learn](http://scikit-learn.org/) (just for the example)\n\nall of which are available via [Anaconda](https://www.continuum.io/downloads).\n\n## Example\n\nTry out a simple example with the included script:\n\n```bash\npython run_example.py\n```\n\n```bash\nEpoch 1 / 10\n[========================================] 100%\tloss: 1.3285    accuracy: 0.5676    val_loss: 1.0450    val_accuracy: 0.5693\n\nEpoch 2 / 10\n[========================================] 100%\tloss: 0.8004    accuracy: 0.8900    val_loss: 0.5804    val_accuracy: 0.8900\n\nEpoch 3 / 10\n[========================================] 100%\tloss: 0.4638    accuracy: 0.8981    val_loss: 0.3845    val_accuracy: 0.8983\n\nEpoch 4 / 10\n[========================================] 100%\tloss: 0.3357    accuracy: 0.9033    val_loss: 0.2998    val_accuracy: 0.9043\n\nEpoch 5 / 10\n[========================================] 100%\tloss: 0.2684    accuracy: 0.9196    val_loss: 0.2462    val_accuracy: 0.9213\n\nEpoch 6 / 10\n[========================================] 100%\tloss: 0.2215    accuracy: 0.9374    val_loss: 0.2061    val_accuracy: 0.9423\n\nEpoch 7 / 10\n[========================================] 100%\tloss: 0.1841    accuracy: 0.9586    val_loss: 0.1738    val_accuracy: 0.9590\n\nEpoch 8 / 10\n[========================================] 100%\tloss: 0.1543    accuracy: 0.9704    val_loss: 0.1478    val_accuracy: 0.9673\n\nEpoch 9 / 10\n[========================================] 100%\tloss: 0.1298    accuracy: 0.9806    val_loss: 0.1266    val_accuracy: 0.9747\n\nEpoch 10 / 10\n[========================================] 100%\tloss: 0.1099    accuracy: 0.9861    val_loss: 0.1094    val_accuracy: 0.9800\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenryre%2Fpytorch-fitmodule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhenryre%2Fpytorch-fitmodule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenryre%2Fpytorch-fitmodule/lists"}