0% found this document useful (0 votes)
17 views5 pages

ANN Analysis

Uploaded by

agwonadavid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views5 pages

ANN Analysis

Uploaded by

agwonadavid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

ANN models Explanation

Sequential model:

Tensorflow.keras.Sequential is a sequential model where the layers are


linearly stacked
A Sequential model is appropriate for a plain stack of layers where each layer
has exactly one input tensor and one output tensor.

Dense
 Tensorflow.keras.layers.Dense defines a dense (fully connected) layer of the
neural network

 Dense(32, activation='relu', input_shape=(xtrain.shape[1],)): This line creates


a dense layer with 32 units (neurons) and ReLU activation function. The
layer receives as input a shape tensor (xtrain.shape[1],), which corresponds to
the format of the input data of the training set. This layer is the first layer of
the model, so we specify the input format.

Activation Function

What is an activation function?

Simply put, an activation function is a function that is added into an artificial


neural network in order to help the network learn complex patterns in the data.
When comparing with a neuron-based model that is in our brains, the
activation function is at the end deciding what is to be fired to the next
neuron. That is exactly what an activation function does in an ANN as well. It
takes in the output signal from the previous cell and converts it into some
form that can be taken as input to the next cell.

Types of activation functions


ReLU: ReLU (Rectified Linear Unit)
Tanh:
Softmax
Sigmoid

More:
https://www.datacamp.com/tutorial/introduction-to-activation-functions-in-
neural-networks

Dropout
 Dropout(0.1): This line adds a dropout layer with a rate of 0.1. Dropout is a
regularization technique that helps prevent overfitting by randomly
deactivating a fraction of neurons during training.

Overfitting is an undesirable machine learning behavior that occurs when the


machine learning model gives accurate predictions for training data but not
for new data. When data scientists use machine learning models for making
predictions, they first train the model on a known data set. Then, based on
this information, the model tries to predict outcomes for new data sets. An
overfit model can give inaccurate predictions and cannot perform well for all
types of new data.
Model Compilation

 loss='binary_crossentropy': We use the binary cross entropy as the loss


function. This loss function is suitable for binary classification problems,
where we are trying to predict one of two classes.

The loss function is a method of evaluating how well your machine


learning algorithm models your featured data set. In other words, loss
functions are a measurement of how good your model is in terms of
predicting the expected outcome.

The cost function and loss function refer to the same context (i.e. the training
process that uses backpropagation to minimize the error between the actual
and predicted outcome). We calculate the cost function as the average of all
loss function values whereas we calculate the loss function for each sample
output compared to its actual value.

The loss function is directly related to the predictions of the model you’ve
built. If your loss function value is low, your model will provide good results.
The loss function (or rather, the cost function) you use to evaluate the model
performance needs to be minimized to improve its performance.

 optimizer='adam': The Adam optimizer will be used to adjust model weights


during training. Adam is a popular optimization algorithm that relies on
stochastic gradient descent methods.

Optimizers are algorithms or methods used to modify or tune the


characteristics of a neural network, such as layer weights, learning rate, etc.,
to reduce the loss and in turn improve the model.
TYPES OF OPTIMIZERS :

1. Gradient Descent

2. Stochastic Gradient Descent

3. Adagrad

4. Adadelta

5. RMSprop

6. Adam

More
https://medium.com/analytics-vidhya/this-blog-post-aims-at-explaining-the-
behavior-of-different-algorithms-for-optimizing-gradient-46159a97a8c1

 metrics=['accuracy']: In addition to the loss function, we also want to track


the accuracy metric during model training and evaluation. Accuracy is a
common measure for evaluating classification model performance.

Training the model

 xtrain and ytrain are the training data, where xtrain contains the resources
(inputs) and ytrain contains the corresponding labels (outputs). This data is
used to adjust model weights during training.
 epochs is the number of times the model will go through the entire training
set. Each epoch consists of a cycle of going through the training data and
adjusting the model weights.
 batch_size is the number of training examples used in a single iteration. The
training set is divided into smaller batches and adjustment of model weights
is performed after each batch.
 validation_data = (xtest, ytest) specifies the validation data to be used during
training. This data is used to evaluate the model's performance on an
independent dataset during training. xtest are the test resources and ytest are
the corresponding labels.

Training Loss

The training loss is a metric used to assess how a deep learning model fits the
training data. That is to say, it assesses the error of the model on the training
set. Note that, the training set is a portion of a dataset used to initially train
the model. Computationally, the training loss is calculated by taking the sum
of errors for each example in the training set.
It is also important to note that the training loss is measured after each batch.
This is usually visualized by plotting a curve of the training loss.

Validation Loss

On the contrary, validation loss is a metric used to assess the performance of


a deep learning model on the validation set. The validation set is a portion of
the dataset set aside to validate the performance of the model. The validation
loss is similar to the training loss and is calculated from a sum of the errors
for each example in the validation set.

You might also like