0
$\begingroup$

I am building CNN algorithm that will output some values. I am using GridSearchCV for parameters tuning and I want to implement progress bar for handling with large datasets but I do not know how to.

Input:

def create_model(units):
    model = Sequential() # defining model
    model.add(Conv1D(filters = 64, kernel_size = 5, activation = 'relu', input_shape = (max_sensor_length, SENSORS))) # first convolution layer
    model.add(MaxPool1D(pool_size = 8)) # first pooling layer
    model.add(Conv1D(filters = 16, kernel_size = 5, activation = 'relu')) # 2. layer
    model.add(MaxPool1D(pool_size = 4))
    model.add(Conv1D(filters = 16, kernel_size = 5, activation = 'relu')) # 3. layer
    model.add(MaxPool1D(pool_size = 4))
    model.add(Flatten()) # adding fully connected layer
    model.add(Dense(units = units, activation = 'relu'))
    model.add(Dense(y_ohe.shape[1], activation = 'softmax')) # adding output layer
    model.compile(loss = 'categorical_crossentropy', 
                  optimizer = 'adam', 
                  metrics = ['accuracy'], 
                  ) # compiling the model
    return model

model = KerasRegressor(model = create_model, units = 5)

batch_size = [5, 10, 30, 50, 100]
epochs = [5, 10, 30, 50, 100]
units = [5, 10, 15, 30, 50, 100]

param_grid = dict(batch_size = batch_size, 
                    epochs = epochs,
                    units = units)

grid = GridSearchCV(estimator = model, 
                    param_grid = param_grid, 
                    n_jobs = -1, 
                    cv = 3, 
                    verbose = 10
                    )

grid_result = grid.fit(X_train, 
                       Y_train, 
                       validation_data = (X_test, Y_test)
                       )
$\endgroup$

1 Answer 1

0
$\begingroup$

From the sklearn documentation on gridsearchCV

verbose (int) Controls the verbosity: the higher, the more messages.

1 : the computation time for each fold and parameter candidate is displayed;

2 : the score is also displayed;

3 : the fold and candidate parameter indexes are also displayed together with the starting time of the computation.

Just set verbose = 1 in the gridsearch parameters (not sure if 10 works?)

Probably you will regret this later as you will end up with a wall of text.

If you are talking about a progress bar for the CNN I would look at tqdm

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.