{"id":13440213,"url":"https://github.com/skorch-dev/skorch","last_synced_at":"2025-12-12T00:53:35.733Z","repository":{"id":38330992,"uuid":"97533515","full_name":"skorch-dev/skorch","owner":"skorch-dev","description":"A scikit-learn compatible neural network library that wraps PyTorch","archived":false,"fork":false,"pushed_at":"2025-04-24T12:58:03.000Z","size":12640,"stargazers_count":6017,"open_issues_count":63,"forks_count":396,"subscribers_count":80,"default_branch":"master","last_synced_at":"2025-05-06T16:17:26.129Z","etag":null,"topics":["hacktoberfest","huggingface","machine-learning","pytorch","scikit-learn"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skorch-dev.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.md","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-07-18T00:13:54.000Z","updated_at":"2025-05-06T15:07:30.000Z","dependencies_parsed_at":"2023-12-13T14:42:12.517Z","dependency_job_id":"e11523f8-f9c0-4d2a-b39e-98b28a9e4954","html_url":"https://github.com/skorch-dev/skorch","commit_stats":{"total_commits":918,"total_committers":62,"mean_commits":"14.806451612903226","dds":0.7200435729847494,"last_synced_commit":"0d3a8ec4533d089dc30d2798134454a4c716b587"},"previous_names":["dnouri/skorch"],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorch-dev%2Fskorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorch-dev%2Fskorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorch-dev%2Fskorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skorch-dev%2Fskorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skorch-dev","download_url":"https://codeload.github.com/skorch-dev/skorch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253919635,"owners_count":21984264,"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":["hacktoberfest","huggingface","machine-learning","pytorch","scikit-learn"],"created_at":"2024-07-31T03:01:20.759Z","updated_at":"2025-12-12T00:53:35.722Z","avatar_url":"https://github.com/skorch-dev.png","language":"Jupyter Notebook","readme":".. image:: https://github.com/skorch-dev/skorch/blob/master/assets/skorch_bordered.svg\n   :width: 30%\n\n------------\n\n|build| |coverage| |docs| |huggingface| |powered|\n\nA scikit-learn compatible neural network library that wraps PyTorch.\n\n.. |build| image:: https://github.com/skorch-dev/skorch/workflows/tests/badge.svg\n    :alt: Test Status\n\n.. |coverage| image:: https://github.com/skorch-dev/skorch/blob/master/assets/coverage.svg\n    :alt: Test Coverage\n\n.. |docs| image:: https://readthedocs.org/projects/skorch/badge/?version=latest\n    :alt: Documentation Status\n    :target: https://skorch.readthedocs.io/en/latest/?badge=latest\n\n.. |huggingface| image:: https://github.com/skorch-dev/skorch/actions/workflows/test-hf-integration.yml/badge.svg\n    :alt: Hugging Face Integration\n    :target: https://github.com/skorch-dev/skorch/actions/workflows/test-hf-integration.yml\n\n.. |powered| image:: https://github.com/skorch-dev/skorch/blob/master/assets/powered.svg\n    :alt: Powered by\n    :target: https://github.com/ottogroup/\n\n=========\nResources\n=========\n\n- `Documentation \u003chttps://skorch.readthedocs.io/en/latest/?badge=latest\u003e`_\n- `Source Code \u003chttps://github.com/skorch-dev/skorch/\u003e`_\n- `Installation \u003chttps://github.com/skorch-dev/skorch#installation\u003e`_\n\n========\nExamples\n========\n\nTo see more elaborate examples, look `here\n\u003chttps://github.com/skorch-dev/skorch/tree/master/notebooks/README.md\u003e`__.\n\n.. code:: python\n\n    import numpy as np\n    from sklearn.datasets import make_classification\n    from torch import nn\n    from skorch import NeuralNetClassifier\n\n    X, y = make_classification(1000, 20, n_informative=10, random_state=0)\n    X = X.astype(np.float32)\n    y = y.astype(np.int64)\n\n    class MyModule(nn.Module):\n        def __init__(self, num_units=10, nonlin=nn.ReLU()):\n            super().__init__()\n\n            self.dense0 = nn.Linear(20, num_units)\n            self.nonlin = nonlin\n            self.dropout = nn.Dropout(0.5)\n            self.dense1 = nn.Linear(num_units, num_units)\n            self.output = nn.Linear(num_units, 2)\n            self.softmax = nn.Softmax(dim=-1)\n\n        def forward(self, X, **kwargs):\n            X = self.nonlin(self.dense0(X))\n            X = self.dropout(X)\n            X = self.nonlin(self.dense1(X))\n            X = self.softmax(self.output(X))\n            return X\n\n    net = NeuralNetClassifier(\n        MyModule,\n        max_epochs=10,\n        lr=0.1,\n        # Shuffle training data on each epoch\n        iterator_train__shuffle=True,\n    )\n\n    net.fit(X, y)\n    y_proba = net.predict_proba(X)\n\nIn an `sklearn Pipeline \u003chttps://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html\u003e`_:\n\n.. code:: python\n\n    from sklearn.pipeline import Pipeline\n    from sklearn.preprocessing import StandardScaler\n\n    pipe = Pipeline([\n        ('scale', StandardScaler()),\n        ('net', net),\n    ])\n\n    pipe.fit(X, y)\n    y_proba = pipe.predict_proba(X)\n\nWith `grid search \u003chttps://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html\u003e`_:\n\n.. code:: python\n\n    from sklearn.model_selection import GridSearchCV\n\n    # deactivate skorch-internal train-valid split and verbose logging\n    net.set_params(train_split=False, verbose=0)\n    params = {\n        'lr': [0.01, 0.02],\n        'max_epochs': [10, 20],\n        'module__num_units': [10, 20],\n    }\n    gs = GridSearchCV(net, params, refit=False, cv=3, scoring='accuracy', verbose=2)\n\n    gs.fit(X, y)\n    print(\"best score: {:.3f}, best params: {}\".format(gs.best_score_, gs.best_params_))\n\n\nskorch also provides many convenient features, among others:\n\n- `Learning rate schedulers \u003chttps://skorch.readthedocs.io/en/stable/callbacks.html#skorch.callbacks.LRScheduler\u003e`_ (Warm restarts, cyclic LR and many more)\n- `Scoring using sklearn (and custom) scoring functions \u003chttps://skorch.readthedocs.io/en/stable/callbacks.html#skorch.callbacks.EpochScoring\u003e`_\n- `Early stopping \u003chttps://skorch.readthedocs.io/en/stable/callbacks.html#skorch.callbacks.EarlyStopping\u003e`_\n- `Checkpointing \u003chttps://skorch.readthedocs.io/en/stable/callbacks.html#skorch.callbacks.Checkpoint\u003e`_\n- `Parameter freezing/unfreezing \u003chttps://skorch.readthedocs.io/en/stable/callbacks.html#skorch.callbacks.Freezer\u003e`_\n- `Progress bar \u003chttps://skorch.readthedocs.io/en/stable/callbacks.html#skorch.callbacks.ProgressBar\u003e`_ (for CLI as well as jupyter)\n- `Automatic inference of CLI parameters \u003chttps://github.com/skorch-dev/skorch/tree/master/examples/cli\u003e`_\n- `Integration with GPyTorch for Gaussian Processes \u003chttps://skorch.readthedocs.io/en/latest/user/probabilistic.html\u003e`_\n- `Integration with Hugging Face 🤗 \u003chttps://skorch.readthedocs.io/en/stable/user/huggingface.html\u003e`_\n\n============\nInstallation\n============\n\nskorch requires Python 3.9 or higher.\n\nconda installation\n==================\n\nYou need a working conda installation. Get the correct miniconda for\nyour system from `here \u003chttps://conda.io/miniconda.html\u003e`__.\n\nTo install skorch, you need to use the conda-forge channel:\n\n.. code:: bash\n\n    conda install -c conda-forge skorch\n\nWe recommend to use a `conda virtual environment \u003chttps://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html\u003e`_.\n\n**Note**: The conda channel is *not* managed by the skorch\nmaintainers. More information is available `here\n\u003chttps://github.com/conda-forge/skorch-feedstock\u003e`__.\n\npip installation\n================\n\nTo install with pip, run:\n\n.. code:: bash\n\n    python -m pip install -U skorch\n\nAgain, we recommend to use a `virtual environment\n\u003chttps://docs.python.org/3/tutorial/venv.html\u003e`_ for this.\n\nFrom source\n===========\n\nIf you would like to use the most recent additions to skorch or\nhelp development, you should install skorch from source.\n\nUsing conda\n-----------\n\nTo install skorch from source using conda, proceed as follows:\n\n.. code:: bash\n\n    git clone https://github.com/skorch-dev/skorch.git\n    cd skorch\n    conda create -n skorch-env python=3.12\n    conda activate skorch-env\n    python -m pip install torch\n    python -m pip install .\n\nIf you want to help developing, run:\n\n.. code:: bash\n\n    git clone https://github.com/skorch-dev/skorch.git\n    cd skorch\n    conda create -n skorch-env python=3.12\n    conda activate skorch-env\n    python -m pip install torch\n    python -m pip install '.[test,docs,dev,extended]'\n\n    py.test  # unit tests\n    pylint skorch  # static code checks\n\nYou may adjust the Python version to any of the supported Python versions.\n\nUsing pip\n---------\n\nFor pip, follow these instructions instead:\n\n.. code:: bash\n\n    git clone https://github.com/skorch-dev/skorch.git\n    cd skorch\n    # create and activate a virtual environment\n    # install pytorch version for your system (see below)\n    python -m pip install .\n\nIf you want to help developing, run:\n\n.. code:: bash\n\n    git clone https://github.com/skorch-dev/skorch.git\n    cd skorch\n    # create and activate a virtual environment\n    # install pytorch version for your system (see below)\n    python -m pip install -e '.[test,docs,dev,extended]'\n\n    py.test  # unit tests\n    pylint skorch  # static code checks\n\nPyTorch\n=======\n\nPyTorch is not covered by the dependencies, since the PyTorch version\nyou need is dependent on your OS and device. For installation\ninstructions for PyTorch, visit the `PyTorch website\n\u003chttp://pytorch.org/\u003e`__. skorch officially supports the last four\nminor PyTorch versions, which currently are:\n\n- 2.6.0\n- 2.7.1\n- 2.8.0\n- 2.9.0\n\nHowever, that doesn't mean that older versions don't work, just that\nthey aren't tested. Since skorch mostly relies on the stable part of\nthe PyTorch API, older PyTorch versions should work fine.\n\nIn general, running this to install PyTorch should work:\n\n.. code:: bash\n\n    python -m pip install torch\n\n==================\nExternal resources\n==================\n\n- @jakubczakon: `blog post\n  \u003chttps://neptune.ai/blog/model-training-libraries-pytorch-ecosystem\u003e`_\n  \"8 Creators and Core Contributors Talk About Their Model Training\n  Libraries From PyTorch Ecosystem\" 2020\n- @BenjaminBossan: `talk 1\n  \u003chttps://www.youtube.com/watch?v=Qbu_DCBjVEk\u003e`_ \"skorch: A\n  scikit-learn compatible neural network library\" at PyCon/PyData 2019\n- @githubnemo: `poster \u003chttps://github.com/githubnemo/skorch-poster\u003e`_\n  for the PyTorch developer conference 2019\n- @thomasjpfan: `talk 2 \u003chttps://www.youtube.com/watch?v=0J7FaLk0bmQ\u003e`_\n  \"Skorch: A Union of Scikit learn and PyTorch\" at SciPy 2019\n- @thomasjpfan: `talk 3 \u003chttps://www.youtube.com/watch?v=yAXsxf2CQ8M\u003e`_\n  \"Skorch - A Union of Scikit-learn and PyTorch\" at PyData 2018\n- @BenjaminBossan: `talk 4 \u003chttps://youtu.be/y_n7BjDCS-M\u003e`_ \"Extend your\n  scikit-learn workflow with Hugging Face and skorch\" at PyData Amsterdam 2023\n  (`slides 4 \u003chttps://github.com/BenjaminBossan/presentations/blob/main/2023-09-14-pydata/presentation.org\u003e`_)\n\n=============\nCommunication\n=============\n\n- `GitHub discussions \u003chttps://github.com/skorch-dev/skorch/discussions\u003e`_: \n  user questions, thoughts, install issues, general discussions.\n\n- `GitHub issues \u003chttps://github.com/skorch-dev/skorch/issues\u003e`_: bug\n  reports, feature requests, RFCs, etc.\n\n- Slack: We run the #skorch channel on the `PyTorch Slack server\n  \u003chttps://pytorch.slack.com/\u003e`_, for which you can `request access\n  here \u003chttps://bit.ly/ptslack\u003e`_.\n","funding_links":[],"categories":["Jupyter Notebook","The Data Science Toolbox","Differential Privacy Tools","Deep Learning Framework","Tools","🤖 Machine Learning \u0026 AI","其他_机器学习与深度学习","Python","机器学习框架","PyTorch Tools, Libraries, and Frameworks"],"sub_categories":["Deep Learning Packages","Interfaces","High-Level DL APIs","Winetricks","Objective-C Tools, Libraries, and Frameworks","Tools","General-Purpose Machine Learning","Mesh networks"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskorch-dev%2Fskorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskorch-dev%2Fskorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskorch-dev%2Fskorch/lists"}