Created
September 9, 2021 14:39
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
early_stopping = callbacks.EarlyStopping( | |
min_delta=0.001, # minimium amount of change to count as an improvement | |
patience=20, # how many epochs to wait before stopping | |
restore_best_weights=True) | |
# Initialising the NN | |
model = Sequential() | |
# layers | |
model.add(Dense(units = 16, kernel_initializer = 'uniform', activation = 'relu', input_dim = 12)) | |
model.add(Dense(units = 8, kernel_initializer = 'uniform', activation = 'relu')) | |
model.add(Dropout(0.5)) | |
model.add(Dense(units = 4, kernel_initializer = 'uniform', activation = 'relu')) | |
model.add(Dropout(0.5)) | |
model.add(Dense(units = 1, kernel_initializer = 'uniform', activation = 'sigmoid')) | |
from tensorflow.keras.optimizers import SGD | |
# Compiling the ANN | |
model.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics = ['accuracy']) | |
# Train the ANN | |
history = model.fit(X_train, y_train, batch_size = 32, epochs = 500,callbacks=[early_stopping], validation_split=0.2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment