Drop out rate in keras
Drop out is a powerful regularization technique for neural networks and deep learning models.
In the dropout technique, randomly selected neurons are ignored during training. Their contribution to the activation of downstream neurons is temporally removed on the forward pass then any weight updates are not applied to the neuron on the backward pass.
Dropout can be implemented by randomly selecting any nodes to be dropped with a given probability (10% or 0.1) each weight update cycle. Dropout is only used during the training of a model is not used when evaluating the skill of the model.
#importing Libraries import pandas as pd import numpy as np from keras.datasets import mnist from sklearn.model_selection import train_test_split from keras.models import Sequential from keras.layers import Dense from keras.layers import Dropout from tensorflow.keras import layers
#Loading Dataset (X_train, y_train), (X_test, y_test) = mnist.load_data()
We will define the model and then define the layers, kernel initializer, and its input nodes shape.
#Model model = Sequential() model.add(layers.Dense(64, kernel_initializer='uniform', input_shape=(10,)))
We will add layers by using 'add', we will specify the dropout rate as 0.2 and 0.1 for both the layers
#Adding Layers model.add(Dense(512)) model.add(Dropout(0.2)) model.add(Dense(256, activation='relu')) model.add(Dropout(0.1))
We will Print the model