Limit CPU Utilization when training Sequential model using Keras

Viewed 26

I am trying to built a sequential model using Keras.

The model is working fine, but its consuming 100% of my system CPU, I need help to limit my system CPU at 80% when this code is running because it's causing alarms.

I am attaching the methods I am using for training the model

def get_model(n_inputs, n_outputs):
  model = Sequential()
  model.add(Dense(2500, input_dim=n_inputs, kernel_initializer='he_uniform',activation='relu'))
  model.add(Dense(n_outputs, activation='sigmoid'))
  model.compile(loss='binary_crossentropy', optimizer='adam')
  return model

Evaluate a model using repeated k-fold cross-validation:

def train_model(X, y):
  results = list()
  n_inputs, n_outputs = X.shape[1], y.shape[1]
  model = get_model(n_inputs, n_outputs)
  model.fit(X, y, verbose=1, epochs=100)
  # make a prediction on the test set
  yhat = model.predict(X)
  # round probabilities to class labels
  yhat = yhat.round()
  # calculate accuracy
  acc = accuracy_score(y, yhat)
  # store result
  print('>%.3f' % acc)
  results.append(acc)
  return model,results

Fitting the model:

 model,results = train_model(X, y)
0 Answers
Related