Dropout is one of the most popular regularization techniques for deep neural networks.
Monte Carlo Dropout may help boost the dropout model even more.
Full Implementation
ys = np.stack([model(X_test, training=True)
for sample in range(100)])
y = ys.mean(axis=0)
Predict() method returns a matrix of shape[NUMBER_OF_INSTANCES, NUMBER_OF_CLASSES]. So you just make several predictions(For the example above, 100 predictions) and stack those matrices and average over them so that you’ll get the same shape as a single prediction.
References:
Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow, 2nd Edition