Can anyone help me to understand why this model does not give reproducible results? It changes the accuracy values for test sets and other validation sets I am using, each time I run it. I am using a defined seed. I can not understand why that is happening.
Below is part of my code:
np.random.seed(7)
# Create the model
def create_model(neurons=190, init_mode='normal', activation='relu', inputDim=8040, dropout_rate=0.8,
learn_rate=0.001, momentum=0.7, weight_constraint=5):
model = Sequential()
model.add(Dense(neurons, input_dim=inputDim, kernel_initializer=init_mode, activation=activation, kernel_constraint=maxnorm(weight_constraint), kernel_regularizer=regularizers.l2(0.002)))
model.add(Dense(1, activation='sigmoid'))
optimizer = RMSprop(lr=learn_rate)
# compile model
model.compile(loss='binary_crossentropy', optimizer='RmSprop', metrics=['accuracy'])
model = create_model()
seed = 7
# Define k-fold cross validation test harness
kfold = StratifiedKFold(n_splits=3, shuffle=True, random_state=seed)
cvscores = []
for train, test in kfold.split(X_train, Y_train):
print("TRAIN:", train, "VALIDATION:", test)
# Fit the model
history = model.fit(X_train, Y_train, epochs=40, batch_size=50, validation_data=(X_test, Y_test), verbose=0)
I would appreciate some comments on it.