Questions tagged [skorch]

skorch is a scikit-learn compatible neural network library that wraps PyTorch.

skorch

Resources

39 questions
7
votes
0 answers

Skorch GridSearchCV: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan

I have data x of dimension (n_samples, time_steps, n_features) for the features and (n_samples, 1, n_labels) for the labels y. From this I create a train, development and test pytorch datasets. I want to use GridSearchCV to do a grid search on the…
Bruno
  • 632
  • 3
  • 10
  • 24
7
votes
1 answer

Passing tensorDataset or Dataloader to skorch

I want to apply cross validation in Pytorch using skorch, so I prepared my model and my tensorDataset which returns (image,caption and captions_length) and so it has X and Y, so I'll not be able to set Y in the method net.fit(dataset) but when I…
6
votes
3 answers

why is my Neural Network stuck at high loss value after the first epochs

I'm doing regression using Neural Networks. It should be a simple task for NN to do, I have 10 features and 1 output that I want to predict. I'm using pytorch for my project but my Model is not learning well. the loss start with a very high value…
basilisk
  • 1,156
  • 1
  • 14
  • 34
5
votes
1 answer

How to pass input dim from fit method to skorch wrapper?

I am trying to incorporate PyTorch functionalities into a scikit-learn environment (in particular Pipelines and GridSearchCV) and therefore have been looking into skorch. The standard documentation example for neural networks looks like import…
gented
  • 1,620
  • 1
  • 16
  • 20
5
votes
1 answer

TypeError: take(): argument 'index' (position 1) must be Tensor, not numpy.ndarray

I'm new to pytorch. I'm trying to do a cross validation, and I found the skorch library, which allow users to use sklearn functions with a torch model. So, I define a neural network class: torch.manual_seed(42) class Netcross(nn.Module): def…
4
votes
1 answer

Multi-output regression using skorch & sklearn pipeline gives runtime error due to dtype

I want to use skorch to do multi-output regression. I've created a small toy example as can be seen below. In the example, the NN should predict 5 outputs. I also want to use a preprocessing step that is incorporated using sklearn pipelines (in this…
Olivier_s_j
  • 5,490
  • 24
  • 80
  • 126
4
votes
1 answer

Get the validation/train loss from Skorch fit

Is there a way to get the train/validation loss from a Skorch fit in e.g a list (if you want to do some plotting, statistics)?
CutePoison
  • 4,679
  • 5
  • 28
  • 63
4
votes
0 answers

what should I do if my regression model stuck at a high value loss?

I'm using neural nets for a regression problem where I have 3 features and I'm trying to predict one continuous value. I noticed that my neural net start learning good but after 10 epochs it get stuck on a high loss value and could not improve…
basilisk
  • 1,156
  • 1
  • 14
  • 34
3
votes
1 answer

Skorch: Help constructing classifier for multiple outputs

I am attempting to learn skorch by translating a simple pytorch model that predicts the 2 digits contained in a set of MNIST multi digit pictures. These pictures contain 2 overlapping digits which are the output lables (y). I am getting the…
3
votes
1 answer

How to pass parameters to forward function of my torch nn.module from skorch.NeuralNetClassifier.fit()

I have extended nn.Module to implement my network whose forward function is like this ... def forward(self, X, **kwargs): batch_size, seq_len = X.size() length = kwargs['length'] embedded = self.embedding(X) # [batch_size, seq_len,…
Bihan
  • 45
  • 2
  • 6
3
votes
2 answers

Why Skorch show NAN in the every epoch?

I want to create my own dataset class based on Dataset class of Skorch because I want to differentiate categorical columns and continuous columns. These categorical columns will be passed through the embedding layers in the model. The result is…
Wong
  • 69
  • 8
2
votes
0 answers

Output of cross_val_predict

I used skorch to train my model which is defined as below, net_reg = NeuralNetRegressor( Network_binaryDC, batch_size=32, lr=0.01, max_epochs=1000, criterion=nn.MSELoss, optimizer=torch.optim.Adam, train_split=None, …
Xiao Zhao
  • 23
  • 2
2
votes
0 answers

can't get skorch to run on GPU

My skorch Neural Net GridsearchCV code is running, it just appears to not be on the GPU so it is slow. Any help appreciated. It takes 13 seconds per epoch. I know that pytorch runs much faster on the GPU. Code: import skorch import torch import…
John H
  • 21
  • 3
2
votes
1 answer

PyToch Skorch passing 3 dimensional input

Im trying to fit a model in PyTorch while using skorch. My problem is, that my model uses an LSTM layer, which expects 3d input and I don't know how to pass the input correctly. When passing a 2d-array to fit() I get an error from PyTorch for the…
1
vote
0 answers

Errors with using a torch dataset with GridSearchCV

Using trainingData, which is a torch.utils.data.Dataset, throws an error about inconsistent lengths: model = NeuralNetClassifier( module=NN, criterion=T.nn.BCELoss, # optimizer=T.optim.Adam, …
1
2 3