{"id":24595,"library":"skorch","title":"skorch","description":"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.","status":"active","version":"1.3.1","language":"python","source_language":"en","source_url":"https://github.com/skorch-dev/skorch","tags":["pytorch","neural-network","scikit-learn","deep-learning"],"install":[{"cmd":"pip install skorch","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency: skorch wraps PyTorch modules","package":"torch","optional":false},{"reason":"Provides compatibility with sklearn API, pipelines, and utilities like GridSearchCV","package":"scikit-learn","optional":false}],"imports":[{"wrong":"from skorch import NeuralNetClassifier","symbol":"NeuralNetClassifier","correct":"from skorch import NeuralNetClassifier"}],"quickstart":{"code":"import torch\nimport torch.nn as nn\nimport numpy as np\nfrom sklearn.datasets import make_classification\nfrom sklearn.model_selection import cross_val_score\nfrom skorch import NeuralNetClassifier\n\nclass MyModule(nn.Module):\n    def __init__(self, num_units=10):\n        super().__init__()\n        self.dense0 = nn.Linear(20, num_units)\n        self.nonlin = nn.ReLU()\n        self.dropout = nn.Dropout(0.5)\n        self.dense1 = 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.softmax(self.dense1(X))\n        return X\n\nX, y = make_classification(1000, 20, n_informative=10, random_state=0)\nX = X.astype(np.float32)\ny = y.astype(np.int64)\n\nnet = NeuralNetClassifier(\n    MyModule,\n    max_epochs=10,\n    lr=0.1,\n    device='cpu',\n    iterator_train__shuffle=True,\n)\nn_scores = cross_val_score(net, X, y, cv=3, scoring='accuracy')\nprint(f\"Cross-validation accuracy: {n_scores.mean():.3f} ± {n_scores.std():.3f}\")","lang":"python","description":"Quickstart: define a PyTorch module, wrap it with NeuralNetClassifier, and use cross_val_score from scikit-learn."},"warnings":[{"fix":"Replace `train_split=None` with `train_split=False`.","message":"Deprecation 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`.","severity":"breaking","affected_versions":">= 1.0"},{"fix":"Cast X to np.float32 and y to np.int64 (or torch tensors with corresponding dtype).","message":"Input data types: skorch expects `X` as float32 and `y` as int64 for classification. Using wrong dtypes may cause silent errors or poor performance.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure your input tensors are on the correct device, or use `device='cpu'`.","message":"Device 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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'1.3.1':33 'api':22 'compat':6 'cross':25 'cross-valid':24 'current':30 'deep':47 'deep-learn':46 'easi':15 'enabl':14 'everi':36 'gridsearchcv':27 'includ':23 'integr':16 'learn':5,20,45,48 'librari':9 'model':13 'month':38 'network':8,42 'neural':7,41 'neural-network':40 'pipelin':29 'pytorch':12,39 'releas':34 'rough':35 'scikit':4,19,44 'scikit-learn':3,18,43 'skorch':1 'valid':26 'version':31 'wrap':11","created_at":"2026-05-01T08:13:55.108955+00:00","updated_at":"2026-05-01T08:13:55.108955+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmp0rifkkom/venv/lib/python3.12/site-packages/skorch/__init__.py\", line 8, in <module>\n    from .history import History\n  File \"/tmp/tmp0rifkkom/venv/lib/python3.12/site-packages/skorch/history.py\", line 6, in <mo"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.4.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://skorch.readthedocs.io","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/skorch/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}