Need help understanding how this Neural Network is working
This is a model I came across, and I need some help understanding how it works
It uses South German Credit Prediction data set from Kaggle
!wget https://archive.ics.uci.edu/ml/machine-learning-databases/00573/SouthGermanCredit.zip
with zipfile.ZipFile('SouthGermanCredit.zip', 'r') as zip_ref:
zip_ref.extractall('./SouthGermanCredit/')
from tensorflow.keras import regularizers
batch_size=32
learning_rate=1e-3
trainX, testX, trainY, testY = train_test_split(features, labels, test_size=0.2, random_state=69)
normalizer = preprocessing.Normalization()
normalizer.adapt(np.array(trainX))
model = tf.keras.Sequential([
normalizer,
layers.Dense(128, activation='elu', kernel_regularizer=regularizers.l2(0.01)),
layers.Dropout(0.5),
layers.Dense(128, activation='elu', kernel_regularizer=regularizers.l2(0.01)),
layers.Dropout(0.5),
layers.Dense(2),
layers.Softmax()])
model.compile(optimizer=keras.optimizers.Adam(learning_rate=learning_rate),
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=False),
metrics=['accuracy'])
model.fit(trainX, trainY, epochs=50, verbose=0, batch_size=batch_size)
test_loss, test_acc = model.evaluate(testX, testY, verbose=2)
dnn_predictions = model.predict(testX)
my questions are:
- What is normalizer doing in the sequential model
- In layers.Dense, what is the shape of the input and the shape of the output?
- What does layers.Dropout(0.5) mean and do?
- What does model.compile do? and why do we need it. This github link also implements the same model, but there is no model.compile anywhere. why?
UPDATE
After i run model.summary(), this is what is get
Model: sequential_16
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
normalization_16 (Normalizat multiple 41
_________________________________________________________________
dense_48 (Dense) multiple 2688
_________________________________________________________________
dropout_32 (Dropout) multiple 0
_________________________________________________________________
dense_49 (Dense) multiple 16512
_________________________________________________________________
dropout_33 (Dropout) multiple 0
_________________________________________________________________
dense_50 (Dense) multiple 258
_________________________________________________________________
softmax_16 (Softmax) multiple 0
=================================================================
Total params: 19,499
Trainable params: 19,458
Non-trainable params: 41
I dont not know what this means
Topic keras tensorflow kaggle neural-network python
Category Data Science