Model Training and Evaluation

Now we are ready to train our model.

Python3




model.fit(X_train, Y_train,
          epochs=5,
          batch_size=64,
          verbose=1,
          validation_data=(X_val, Y_val))


Output:

Epoch 1/5
428/428 [==============================] - 5s 8ms/step - loss: 1.8563 - auc: 0.6886 - val_loss: 1.6245 - val_auc: 0.7530
Epoch 2/5
428/428 [==============================] - 3s 7ms/step - loss: 1.6319 - auc: 0.7554 - val_loss: 1.5624 - val_auc: 0.7769
Epoch 3/5
428/428 [==============================] - 4s 8ms/step - loss: 1.5399 - auc: 0.7845 - val_loss: 1.5510 - val_auc: 0.7814
Epoch 4/5
428/428 [==============================] - 5s 11ms/step - loss: 1.4883 - auc: 0.7999 - val_loss: 1.5106 - val_auc: 0.7929
Epoch 5/5
428/428 [==============================] - 3s 8ms/step - loss: 1.4408 - auc: 0.8146 - val_loss: 1.4992 - val_auc: 0.7971

By using this neural network with two hidden layers we have achieved a 0.8 AUC-ROC score which implies that the predictions made will be around 80% accurate.

Python3




results = model.evaluate(X_val, Y_val, verbose=0)
print('Validation loss :', results[0])
print('Validation Accuracy :', results[1])


Output:

Validation loss : 1.4992401599884033
Validation Accuracy : 0.7971429824829102


Hidden Layer Perceptron in TensorFlow

In this article, we will learn about hidden layer perceptron. A hidden layer perceptron is nothing but a hi-fi terminology for a neural network with one or more hidden layers. The purpose which is being served by these hidden layers is that they help to learn complex and non-linear functions for a task.

Hidden Layer Perceptron in TensorFlow

The above image is the simplest representation of the hidden layer perceptron with a single hidden layer. Here we can see that the input for the final layer is the neurons of the hidden layers. So, in a hidden layer perceptron network input for the current layer is the output of the previous layer.

We will try to understand how one can implement a Hidden layer perceptron network using TensorFlow. Also, the data used for this purpose is the famous Facial Recognition dataset.

Similar Reads

Importing Libraries and Dataset

Pandas – This library helps to load the data frame in a 2D array format and has multiple functions to perform analysis tasks in one go. Numpy – Numpy arrays are very fast and can perform large computations in a very short time. Matplotlib – This library is used to draw visualizations. Sklearn – This module contains multiple libraries having pre-implemented functions to perform tasks from data preprocessing to model development and evaluation. OpenCV – This is an open-source library mainly focused on image processing and handling. Tensorflow – This is an open-source library that is used for Machine Learning and Artificial intelligence and provides a range of functions to achieve complex functionalities with single lines of code....

Data Visualization

...

Model Training and Evaluation

...

Contact Us