Registry / ai-ml / skorch

skorch

JSON →
library1.4.0pypypiunverified

A scikit-learn compatible neural network library that wraps PyTorch models, enabling easy integration with scikit-learn's API, including cross-validation, GridSearchCV, and pipelines. Current version is 1.3.1, released roughly every few months.

pip install skorch
INSTALL
IMPORT
SIG · SKORCH
S
skorch
ai-mlpythonv1.4.0
Install
10.2s avg
Import
—
Disk
283MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
build_error
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 10.2s · import 0.000s · 273MB
283MB installed
● package 283MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NeuralNetClassifier
✓ from skorch import NeuralNetClassifier
✗ from skorch import NeuralNetClassifier

Quickstart: define a PyTorch module, wrap it with NeuralNetClassifier, and use cross_val_score from scikit-learn.

import torch import torch.nn as nn import numpy as np from sklearn.datasets import make_classification from sklearn.model_selection import cross_val_score from skorch import NeuralNetClassifier class MyModule(nn.Module): def __init__(self, num_units=10): super().__init__() self.dense0 = nn.Linear(20, num_units) self.nonlin = nn.ReLU() self.dropout = nn.Dropout(0.5) self.dense1 = nn.Linear(num_units, 2) self.softmax = nn.Softmax(dim=-1) def forward(self, X, **kwargs): X = self.nonlin(self.dense0(X)) X = self.dropout(X) X = self.softmax(self.dense1(X)) return X X, y = make_classification(1000, 20, n_informative=10, random_state=0) X = X.astype(np.float32) y = y.astype(np.int64) net = NeuralNetClassifier( MyModule, max_epochs=10, lr=0.1, device='cpu', iterator_train__shuffle=True, ) n_scores = cross_val_score(net, X, y, cv=3, scoring='accuracy') print(f"Cross-validation accuracy: {n_scores.mean():.3f} ± {n_scores.std():.3f}")
Debug
Known issues
breakingDeprecation of `train_split=None` for disabling validation: In skorch 1.0, passing `train_split=None` to disable validation was deprecated. For explicit no validation, use `train_split=False`.
fix
Replace `train_split=None` with `train_split=False`.
affects: >= 1.0
gotchaInput data types: skorch expects `X` as float32 and `y` as int64 for classification. Using wrong dtypes may cause silent errors or poor performance.
fix
Cast X to np.float32 and y to np.int64 (or torch tensors with corresponding dtype).
affects: all
gotchaDevice specification: when using `device='cuda'`, the entire model and data must be on the same device. Forgetting to move data to the GPU can cause runtime errors.
fix
Ensure your input tensors are on the correct device, or use `device='cpu'`.
affects: all
Upgrade
Version history
1.4.0latest on PyPI · released May 14, 2026
Audit
Dependencies
torchrequiredCore dependency: skorch wraps PyTorch modules
scikit-learnrequiredProvides compatibility with sklearn API, pipelines, and utilities like GridSearchCV
Agent activity
30 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources
skorch — pip install skorch · libregistry