Experiment 1
Experiment 1
Experiment 1
Aim:
To implement a deep feed-forward neural network for a given problem.
Pre-Lab Questions:
1. What is a deep feed-forward neural network?
A deep feed-forward neural network (DFNN) is a type of artificial neural network where
connections between the nodes do not form cycles. It's called "deep" because it consists of
multiple layers of neurons, including an input layer, several hidden layers, and an output layer.
Each neuron in a layer is connected to every neuron in the subsequent layer, and information
flows in one direction—from input to output—without looping back. The network's depth
and complexity enable it to model and learn complex patterns and relationships in data,
making it a powerful tool for tasks like classification, regression, and more.
Activation functions are mathematical functions applied to the output of each neuron in a
neural network, determining whether the neuron should be activated or not. They introduce
non-linearity into the model, enabling the network to learn complex patterns and
relationships in data that linear functions alone cannot capture. Without activation functions,
even a deep network would behave like a single-layer perceptron, limiting its ability to solve
intricate tasks. Common activation functions include ReLU, sigmoid, and tanh, each offering
different advantages for learning efficiency and model performance. They are crucial for
enabling neural networks to approximate complex functions and perform well on diverse
tasks.
A loss function quantifies the difference between the neural network's predicted outputs and
the actual target values, serving as a measure of model performance. During training, it
provides a numerical value representing how well or poorly the network is performing on a
given task. The goal of training is to minimize this loss by adjusting the network's weights
through optimization algorithms like gradient descent. By minimizing the loss function, the
network learns to make predictions that are closer to the actual values, thereby improving its
accuracy and effectiveness in solving the task at hand.
Problem Statement:
Title – Predicting the presence or absence of objects in ionosphere of earth based on various
signals received.
Objective – To build a deep feed-forward neural network that takes in the 33 signal inputs
obtained from various devices monitoring the ionosphere of earth and outputs the
probability of absence of objects in the said layer.
Tools/Libraries – tensorflow (for building and training the model), ucimlrepo (for dataset).
Implementation:
Following is the step by step implementation of the above problem statement as carried out
on google colab (Notebook - FeedForwardNetwork)
b. Encoding the output class ‘g’ as 0 (if object is present) and ‘b’ as 1 (if no detection of object)-
df['Class'] = df['Class'].map({'g': 0, 'b': 1})
c. Normalizing the data and splitting it into train and validation sets (7:3 split)-
df_train = df.sample(frac=0.7, random_state=0)
df_valid = df.drop(df_train.index)
max_ = df_train.max(axis=0)
min_ = df_train.min(axis=0)
history = model.fit(
X_train, y_train,
validation_data=(X_valid, y_valid),
batch_size=512,
epochs=1000,
callbacks=[early_stopping],
verbose=0,
)
Evolution of Total loss(Blue Line) and Validation Loss (Orange Line) as Epochs Progress
predicted_output = model.predict(input_data.T)
input_data = pd.DataFrame(X_valid.loc[0])
predicted_output = model.predict(input_data.T)
Inferences:
• The trained model was found to have a validation accuracy of 84.76% at around 600
epochs, after which, no significant change in accuracy was observed under the
architecture where 2 hidden layers, each with 4 neurons, were considered.
• Similarly, the loss value for validation set was found to be stabilized at 0.3532.
• The new architecture (as described above) showed an improvement in accuracy from
75% (as implemented during lab) to 84.76% (with an additional hidden layer).
• On using the trained model to predict the presence of objects in ionosphere, the model
was accurately able to match the true output as mentioned in the last section of
implementation.