Hyperparameter using skorch - How to set some optimizer as parameter?

Hi Guys,

I’m trying to set a dict with some parameters, like optimizers and others. How I should do?

Here is my code:

class Net(torch.nn.Module):
    def __init__(self):
        A feedForward neural network.
            n_feature: How many of features in your data
            n_hidden:  How many of neurons in the hidden layer
            n_output:  How many of neuros in the output leyar (defaut=1)
        super(Net, self).__init__()
        self.hidden = torch.nn.Linear(D_in, H, bias=True)   # hidden layer
        self.predict = torch.nn.Linear(H, D_out, bias=True)   # output layer
        self.n_feature, self.n_hidden, self.n_output = D_in, H, D_out
    def forward(self, x,**kwargs):
            x: Features to predict
        x = torch.sigmoid(self.hidden(x))      # activation function for hidden layer
        x = torch.sigmoid(self.predict(x))     # linear output
        return x
from skorch import NeuralNetRegressor
net = NeuralNetRegressor(Net
                         , max_epochs=100
                         , lr=0.001
                         , verbose=1)
X_trf = X
y_trf = y.reshape(-1, 1)
from sklearn.model_selection import GridSearchCV
#from sklearn.metrics import SCORERS

params = {
    'lr': [0.001,0.005, 0.01, 0.05, 0.1, 0.2, 0.3],
    'max_epochs': list(range(500,5500, 500))

gs = GridSearchCV(net, params, refit=False, scoring='r2', verbose=1, cv=10)

gs.fit(X_trf, y_trf)

Hi, dedeco,
Have you solve this issue. I met same question.

Thanks and best regards