skorch documentation¶
A scikit-learn compatible neural network library that wraps PyTorch.
Introduction¶
The goal of skorch is to make it possible to use PyTorch with sklearn. This is achieved by providing a wrapper around PyTorch that has an sklearn interface.
skorch does not re-invent the wheel, instead getting as much out of your way as possible. If you are familiar with sklearn and PyTorch, you don’t have to learn any new concepts, and the syntax should be well known. (If you’re not familiar with those libraries, it is worth getting familiarized.)
Additionally, skorch abstracts away the training loop, making a
lot of boilerplate code obsolete. A simple net.fit(X, y)
is
enough. Out of the box, skorch works with many types of data, be
it PyTorch Tensors, NumPy arrays, Python dicts, and so
on. However, if you have other data, extending skorch is easy to
allow for that.
Overall, skorch aims at being as flexible as PyTorch while having a clean interface as sklearn.
If you use skorch, please use this BibTeX entry:
@manual{skorch,
author = {Marian Tietz and Thomas J. Fan and Daniel Nouri and Benjamin Bossan and {skorch Developers}},
title = {skorch: A scikit-learn compatible neural network library that wraps PyTorch},
month = jul,
year = 2017,
url = {https://skorch.readthedocs.io/en/stable/}
}
User’s Guide¶
- Installation
- Quickstart
- Tutorials
- NeuralNet
- Callbacks
- Dataset
- Saving and Loading
- Gaussian Processes
- History
- Toy
- Helper
- REST Service
- Parallelism
- Customization
- Performance
- Hugging Face Integration
- Support for Large Language Models
- FAQ
- How do I apply L2 regularization?
- How can I continue training my model?
- How do I shuffle my train batches?
- How do I use sklearn GridSeachCV when my data is in a dictionary?
- How do I use sklearn GridSeachCV when my data is in a dataset?
- I want to use sample_weight, how can I do this?
- I already split my data into training and validation sets, how can I use them?
- What happens when NeuralNet is passed an initialized Pytorch module?
- How do I use a PyTorch Dataset with skorch?
- How can I deal with multiple return values from forward?
- How can I perform gradient accumulation with skorch?
- How can I dynamically set the input size of the PyTorch module based on the data?
- How do I implement a score method on the net that returns the loss?
- How can I set the random seed of my model?
- Migration guide
API Reference¶
If you are looking for information on a specific function, class or method, this part of the documentation is for you.