Error in using skorch

username: Prak_kas
cooked: <p>When I try to use skorch for cross validation to the model… using following code,</p>
<pre><code>from skorch import NeuralNetClassifier
epochs = n_iters / (len(X_1) / batch_size)
epochs2= n_iters / (len(X_2) / batch_size)
input_dim=3
output_dim = 1
lr_rate = 0.001

class LogisticRegression1(torch.nn.Module):
    def __init__(self, input_dim=3):
        super(LogisticRegression1, self).__init__()
        self.linear = torch.nn.Linear(input_dim,1)
        self.sigmoid=nn.Sigmoid()
        #self.linear = torch.nn.Linear(2*input_dim, output_dim)
        #raise NotImplementedError()

    def forward(self, x):
        outputs = self.linear(x)
        #outputs = torch.sigmoid(outputs)
        #outputs=self.sigmoid(outputs)
        return outputs
  

    T=torch.cat((T_1,T_2), 0)
    T=torch.tensor(T, dtype=torch.long)


    net = NeuralNetClassifier(
        LogisticRegression1,
        criterion=torch.nn.BCEWithLogitsLoss(),
        max_epochs=10,
        lr=0.1,
        # Shuffle training data on each epoch
        iterator_train__shuffle=True,
    )


    net.fit(X, T)
    y_proba = net.predict_proba(X)
</code></pre>
<p>I am getting following error</p>
<pre><code>---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-10-7feb0459b903&gt; in &lt;module&gt;()
     17 #y_proba = net.predict_proba(X)
     18 
---&gt; 19 net.fit(X, T)
     20 y_proba = net.predict_proba(X)
     21 

4 frames
/usr/local/lib/python3.6/dist-packages/skorch/classifier.py in fit(self, X, y, **fit_params)
    120         # this is actually a pylint bug:
    121         # https://github.com/PyCQA/pylint/issues/1085
 --&gt; 122         return super(NeuralNetClassifier, self).fit(X, y, **fit_params)
    123 
    124     def predict_proba(self, X):

/usr/local/lib/python3.6/dist-packages/skorch/net.py in fit(self, X, y, **fit_params)
    848         """
    849         if not self.warm_start or not self.initialized_:
--&gt; 850             self.initialize()
    851 
    852         self.partial_fit(X, y, **fit_params)

/usr/local/lib/python3.6/dist-packages/skorch/net.py in initialize(self)
    546         self.initialize_virtual_params()
    547         self.initialize_callbacks()
--&gt; 548         self.initialize_criterion()
    549         self.initialize_module()
    550         self.initialize_optimizer()

/usr/local/lib/python3.6/dist-packages/skorch/net.py in initialize_criterion(self)
    434         """Initializes the criterion."""
    435         criterion_params = self._get_params_for('criterion')
--&gt; 436         self.criterion_ = self.criterion(**criterion_params)
    437         if isinstance(self.criterion_, torch.nn.Module):
    438             self.criterion_ = self.criterion_.to(self.device)

/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in __call__(self, *input, 
**kwargs)
    539             result = self._slow_forward(*input, **kwargs)
    540         else:
--&gt; 541             result = self.forward(*input, **kwargs)
    542         for hook in self._forward_hooks.values():
    543             hook_result = hook(self, input, result)

TypeError: forward() missing 2 required positional arguments: 'input' and 'target'
</code></pre>
<p>Any help is appreciated</p>