{"id":13487064,"url":"https://github.com/GRAAL-Research/poutyne","last_synced_at":"2025-03-27T21:31:52.231Z","repository":{"id":29570900,"uuid":"113485248","full_name":"GRAAL-Research/poutyne","owner":"GRAAL-Research","description":"A simplified framework and utilities for PyTorch","archived":false,"fork":false,"pushed_at":"2023-07-09T16:15:44.000Z","size":18164,"stargazers_count":560,"open_issues_count":8,"forks_count":62,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-05-23T06:48:16.534Z","etag":null,"topics":["data-science","deep-learning","keras","machine-learning","neural-network","python","pytorch"],"latest_commit_sha":null,"homepage":"https://poutyne.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GRAAL-Research.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"freud14"}},"created_at":"2017-12-07T18:30:17.000Z","updated_at":"2024-05-13T18:49:04.000Z","dependencies_parsed_at":"2023-01-14T15:12:51.768Z","dependency_job_id":"a69ffd42-277a-4653-9709-2e1b68546c10","html_url":"https://github.com/GRAAL-Research/poutyne","commit_stats":null,"previous_names":["graal-research/pytoune"],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GRAAL-Research%2Fpoutyne","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GRAAL-Research%2Fpoutyne/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GRAAL-Research%2Fpoutyne/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GRAAL-Research%2Fpoutyne/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GRAAL-Research","download_url":"https://codeload.github.com/GRAAL-Research/poutyne/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245927312,"owners_count":20695210,"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":["data-science","deep-learning","keras","machine-learning","neural-network","python","pytorch"],"created_at":"2024-07-31T18:00:54.954Z","updated_at":"2025-03-27T21:31:50.792Z","avatar_url":"https://github.com/GRAAL-Research.png","language":"Python","funding_links":["https://github.com/sponsors/freud14","https://github.com/sponsors/freud14)!"],"categories":["The Data Science Toolbox","Python","Pytorch \u0026 related libraries｜Pytorch \u0026 相关库","Pytorch \u0026 related libraries","Pytorch实用程序"],"sub_categories":["Deep Learning Packages","Other libraries｜其他库:","Other libraries:"],"readme":"![Poutyne Logo](https://raw.githubusercontent.com/GRAAL-Research/poutyne/master/docs/source/_static/logos/poutyne-dark.png)\n\n[![poutyne version - PyPI](https://img.shields.io/pypi/v/poutyne)](https://pypi.org/project/poutyne/)\n![PyPI status](https://img.shields.io/pypi/status/poutyne.svg)\n[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](http://www.gnu.org/licenses/lgpl-3.0)\n![Python version - PyPI](https://img.shields.io/pypi/pyversions/poutyne.svg)\n[![CI/CD](https://github.com/GRAAL-Research/poutyne/actions/workflows/main.yml/badge.svg)](https://github.com/GRAAL-Research/poutyne/actions/workflows/main.yml)\n[![codecov](https://codecov.io/gh/GRAAL-Research/poutyne/branch/master/graph/badge.svg?token=H8D1nZ1wTR)](https://codecov.io/gh/GRAAL-Research/poutyne)\n[![Downloads](https://pepy.tech/badge/poutyne)](https://pepy.tech/project/poutyne)\n\n## Here is Poutyne.\n\nPoutyne is a simplified framework for [PyTorch](https://pytorch.org/) and handles much of the boilerplating code needed to train neural networks.\n\nUse Poutyne to:\n\n- Train models easily.\n- Use callbacks to save your best model, perform early stopping and much more.\n\nRead the documentation at [Poutyne.org](https://poutyne.org).\n\nPoutyne is compatible with the **latest version of PyTorch** and **Python \u003e= 3.8**.\n\n### Cite\n\n```\n@misc{Paradis_Poutyne_A_Simplified_2020,\n    author = {Paradis, Frédérik and Beauchemin, David and Godbout, Mathieu and Alain, Mathieu and Garneau, Nicolas and Otte, Stefan and Tremblay, Alexis and Bélanger, Marc-Antoine and Laviolette, François},\n    title  = {{Poutyne: A Simplified Framework for Deep Learning}},\n    year   = {2020},\n    url    = {https://poutyne.org}\n}\n```\n\n---\n\n## Getting started: few seconds to Poutyne\n\nThe core data structure of Poutyne is a [Model](poutyne/framework/model.py), a way to train your own [PyTorch](https://pytorch.org/docs/master/nn.html) neural networks.\n\nHow Poutyne works is that you create your [PyTorch](https://pytorch.org/docs/master/nn.html) module (neural network) as usual but when comes the time to train it you feed it into the Poutyne Model, which handles all the steps, stats and callbacks, similar to what [Keras](https://keras.io) does.\n\nHere is a simple example:\n\n```python\n# Import the Poutyne Model and define a toy dataset\nfrom poutyne import Model\nimport torch\nimport torch.nn as nn\nimport numpy as np\nimport torchmetrics\n\nnum_features = 20\nnum_classes = 5\nhidden_state_size = 100\n\nnum_train_samples = 800\ntrain_x = np.random.randn(num_train_samples, num_features).astype('float32')\ntrain_y = np.random.randint(num_classes, size=num_train_samples).astype('int64')\n\nnum_valid_samples = 200\nvalid_x = np.random.randn(num_valid_samples, num_features).astype('float32')\nvalid_y = np.random.randint(num_classes, size=num_valid_samples).astype('int64')\n\nnum_test_samples = 200\ntest_x = np.random.randn(num_test_samples, num_features).astype('float32')\ntest_y = np.random.randint(num_classes, size=num_test_samples).astype('int64')\n```\n\nSelect a PyTorch device so that it runs on GPU if you have one:\n\n```python\ncuda_device = 0\ndevice = torch.device(\"cuda:%d\" % cuda_device if torch.cuda.is_available() else \"cpu\")\n```\n\nCreate yourself a [PyTorch](https://pytorch.org/docs/master/nn.html) network:\n\n```python\nnetwork = nn.Sequential(\n    nn.Linear(num_features, hidden_state_size),\n    nn.ReLU(),\n    nn.Linear(hidden_state_size, num_classes)\n)\n```\n\nYou can now use Poutyne's model to train your network easily:\n\n```python\nmodel = Model(\n    network,\n    'sgd',\n    'cross_entropy',\n    batch_metrics=['accuracy'],\n    epoch_metrics=['f1', torchmetrics.AUROC(num_classes=num_classes, task=\"multiclass\")],\n    device=device\n)\nmodel.fit(\n    train_x, train_y,\n    validation_data=(valid_x, valid_y),\n    epochs=5,\n    batch_size=32\n)\n```\n\nSince Poutyne is inspired by [Keras](https://keras.io), one might have notice that this is really similar to some of its [functions](https://keras.io/models/model/).\n\nYou can evaluate the performances of your network using the `evaluate` method of Poutyne's model:\n\n```python\nloss, (accuracy, f1score) = model.evaluate(test_x, test_y)\n```\n\nOr only predict on new data:\n\n```python\npredictions = model.predict(test_x)\n```\n\n[See the complete code here.](https://github.com/GRAAL-Research/poutyne/blob/master/examples/basic_random_classification.py) Also, [see this](https://github.com/GRAAL-Research/poutyne/blob/master/examples/basic_random_regression.py) for an example for regression.\n\nOne of the strengths Poutyne are [callbacks](https://poutyne.org/callbacks.html). They allow you to save checkpoints, log training statistics and more. See this [notebook](https://github.com/GRAAL-Research/poutyne/blob/master/examples/introduction_pytorch_poutyne.ipynb) for an introduction to callbacks. In that vein, Poutyne also offers an [ModelBundle class](https://poutyne.org/experiment.html#poutyne.ModelBundle) that offers automatic checkpointing, logging and more using callbacks under the hood. Here is an example of usage.\n\n```python\nfrom poutyne import ModelBundle\n\n# Everything is saved in ./saves/my_classification_network\nmodel_bundle = ModelBundle.from_network(\n    './saves/my_classification_network', network, optimizer='sgd', task='classif', device=device\n)\n\nmodel_bundle.train_data(train_x, train_y, validation_data=(valid_x, valid_y), epochs=5)\n\nmodel_bundle.test_data(test_x, test_y)\n```\n\n[See the complete code here.](https://github.com/GRAAL-Research/poutyne/blob/master/examples/basic_random_classification_with_model_bundle.py) Also, [see this](https://github.com/GRAAL-Research/poutyne/blob/master/examples/basic_random_regression_with_model_bundle.py) for an example for regression.\n\n---\n\n## Installation\n\nBefore installing Poutyne, you must have the latest version of [PyTorch](https://pytorch.org/) in your environment.\n\n- **Install the stable version of Poutyne:**\n\n```sh\npip install poutyne\n```\n\n- **Install the latest development version of Poutyne:**\n\n```sh\npip install -U git+https://github.com/GRAAL-Research/poutyne.git@dev\n```\n\n- **Install and develop on top of the provided Docker Image**\n\n```sh\ndocker pull ghcr.io/graal-research/poutyne:latest\n```\n\n---\n\n## Learning Material\n\n### Blog posts\n\n- [Medium PyTorch post](https://medium.com/pytorch/poutyne-a-simplified-framework-for-deep-learning-in-pytorch-74b1fc1d5a8b) - Presentation of the basics of Poutyne and how it can help you be more efficient when developing neural networks with PyTorch.\n\n### Examples\n\nLook at notebook files with full working [examples](https://github.com/GRAAL-Research/poutyne/blob/master/examples/):\n\n- [introduction.ipynb](https://github.com/GRAAL-Research/poutyne/blob/master/examples/introduction.ipynb) ([tutorial version](https://github.com/GRAAL-Research/poutyne/blob/master/tutorials/introduction_pytorch_poutyne_tutorial.ipynb)) - comparison of Poutyne with bare PyTorch and usage examples of Poutyne callbacks and the ModelBundle class.\n- [tips_and_tricks.ipynb](https://github.com/GRAAL-Research/poutyne/blob/master/examples/tips_and_tricks.ipynb) - tips and tricks using Poutyne\n- [sequence_tagging.ipynb](https://github.com/GRAAL-Research/poutyne/blob/master/examples/sequence_tagging.ipynb) - Sequence tagging with an RNN\n- [transfer_learning.ipynb](https://github.com/GRAAL-Research/poutyne/blob/master/examples/transfer_learning.ipynb) - transfer learning on `ResNet-18` on the [CUB-200](http://www.vision.caltech.edu/visipedia/CUB-200-2011.html) dataset.\n- [policy_interface.ipynb](https://github.com/GRAAL-Research/poutyne/blob/master/examples/policy_interface.ipynb) - example of policies\n- [image_reconstruction.ipynb](https://github.com/GRAAL-Research/poutyne/blob/master/examples/image_reconstruction.ipynb) - example of image reconstruction\n- [classification_and_regression.ipynb](https://github.com/GRAAL-Research/poutyne/blob/master/examples/classification_and_regression.ipynb) - example of multitask learning with classification and regression\n- [semantic_segmentation.ipynb](https://github.com/GRAAL-Research/poutyne/blob/master/examples/semantic_segmentation.ipynb) - example of semantic segmentation\n\nor in `Google Colab`:\n\n- [introduction.ipynb](https://colab.research.google.com/github/GRAAL-Research/poutyne/blob/master/examples/introduction.ipynb) ([tutorial version](https://colab.research.google.com/github/GRAAL-Research/poutyne/blob/master/tutorials/introduction_pytorch_poutyne_tutorial.ipynb)) - comparison of Poutyne with bare PyTorch and usage examples of Poutyne callbacks and the ModelBundle class.\n- [tips_and_tricks.ipynb](https://colab.research.google.com/github/GRAAL-Research/poutyne/blob/master/examples/tips_and_tricks.ipynb) - tips and tricks using Poutyne\n- [sequence_tagging.ipynb](https://colab.research.google.com/github/GRAAL-Research/poutyne/blob/master/examples/sequence_tagging.ipynb) - Sequence tagging with an RNN\n- [transfer_learning.ipynb](https://colab.research.google.com/github/GRAAL-Research/poutyne/blob/master/examples/transfer_learning.ipynb) - transfer learning on `ResNet-18` on the [CUB-200](http://www.vision.caltech.edu/visipedia/CUB-200-2011.html) dataset.\n- [policy_interface.ipynb](https://colab.research.google.com/github/GRAAL-Research/poutyne/blob/master/examples/policy_interface.ipynb) - example of policies\n- [image_reconstruction.ipynb](https://colab.research.google.com/github/GRAAL-Research/poutyne/blob/master/examples/image_reconstruction.ipynb) - example of image reconstruction\n- [classification_and_regression.ipynb](https://colab.research.google.com/github/GRAAL-Research/poutyne/blob/master/examples/classification_and_regression.ipynb) - example of multitask learning with classification and regression\n- [semantic_segmentation.ipynb](https://colab.research.google.com/github/GRAAL-Research/poutyne/blob/master/examples/semantic_segmentation.ipynb) - example of semantic segmentation\n\n### Videos\n\n- [Presentation on Poutyne](https://youtu.be/gQ3SW5r7HSs) given at one of the weekly presentations of the Institute Intelligence and Data (IID) of Université Laval. [Slides](https://github.com/GRAAL-Research/poutyne/blob/master/slides/poutyne.pdf) and the [associated Latex source code](https://github.com/GRAAL-Research/poutyne/blob/master/slides/src/) are also available.\n\n---\n\n## Contributing to Poutyne\n\nWe welcome user input, whether it is regarding bugs found in the library or feature propositions ! Make sure to have a look at our [contributing guidelines](https://github.com/GRAAL-Research/poutyne/blob/master/CONTRIBUTING.md) for more details on this matter.\n\n---\n\n## Sponsors\n\nThis project supported by [Frédérik Paradis](https://github.com/freud14/) and [David Beauchemin](https://github.com/davebulaval). [Join the sponsors - show your ❤️ and support, and appear on the list](https://github.com/sponsors/freud14)!\n\n---\n\n## License\n\nPoutyne is LGPLv3 licensed, as found in the [LICENSE file](https://github.com/GRAAL-Research/poutyne/blob/master/LICENSE).\n\n---\n\n## Why this name, Poutyne?\n\nPoutyne's name comes from [poutine](https://en.wikipedia.org/wiki/Poutine), the well-known dish from Quebec. It is usually composed of French fries, squeaky cheese curds and brown gravy. However, in Quebec, poutine also has the meaning of something that is an [\"ordinary or common subject or activity\"](https://fr.wiktionary.org/wiki/poutine). Thus, Poutyne will get rid of the ordinary boilerplate code that plain [PyTorch](https://pytorch.org) training usually entails.\n\n![Poutine](https://upload.wikimedia.org/wikipedia/commons/4/4e/La_Banquise_Poutine_%28cropped%29.jpg)\n_Yuri Long from Arlington, VA, USA \\[[CC BY 2.0](https://creativecommons.org/licenses/by/2.0)\\]_\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGRAAL-Research%2Fpoutyne","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGRAAL-Research%2Fpoutyne","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGRAAL-Research%2Fpoutyne/lists"}