UNIT 2 Self Notes
UNIT 2 Self Notes
UNIT 2 Self Notes
• Same Padding: In the same padding, padding is added to the input feature map such that the
size of the output feature map is the same as the input feature map. This is useful when we want
to preserve the spatial dimensions of the feature maps.
Striding
A strided convolution is another basic building block of convolution that is used in
Convolutional Neural Networks.
3. Fully Connected Layer
After several convolutional and pooling layers, fully connected layers are
often used to make predictions based on the learned features. These layers
connect every neuron to every neuron in the previous and subsequent
layers.
These layers are usually placed before the output layer and form the last few layers
of a CNN Architecture.
4. Dropout
• When all the features are connected to the FC layer, it can cause overfitting in
the training dataset.
• Overfitting occurs when a particular model works so well on the training data
causing a negative impact in the model’s performance when used on a new data.
• To overcome this problem, a dropout layer is utilized wherein a few neurons are
dropped from the neural network during training process resulting in reduced
size of the model.
• Dropout results in improving the performance of a machine learning model as it
prevents overfitting by making the network simpler.
5. Activation Functions
• Finally, one of the most important parameters of the CNN model is the
activation function.
• It adds non-linearity to the network.
• There are several commonly used activation functions such as the ReLU,
Softmax, tanH and the Sigmoid functions
Transfer Learning
Transfer learning is a technique in deep learning where a pre-trained neural
network model is used (means a model that is already trained) as a starting point
for a new, related task, instead of training a neural network from scratch for a
specific task.
The idea is that the knowledge learned from one task can be transferred to another
task, potentially saving a lot of training time and data.
Image Classification
Step 1: Data Preparation
o Collect and Prepare Your Dataset: Gather a labeled dataset of images for
training and testing. Ensure that the dataset is balanced and representative of the
classes you want to classify.
o Data Preprocessing: Preprocess the images by resizing them to a consistent
size (e.g., 224x224 pixels), normalizing pixel values (usually in the range [0, 1]),
and augmenting the data if needed (applying random transformations like
rotation, flipping, and cropping to increase dataset diversity).
o Split the Dataset: Divide the dataset into training, validation, and test sets.
Typically, you allocate a larger portion to training (e.g., 70-80%) and the rest to
validation and testing.
Step 2: Build the CNN Model
o Choose a Pre-trained Model (Optional): Consider using a pre-trained CNN
model like VGG, ResNet, Inception, or MobileNet as a starting point. These
models are trained on large datasets (e.g., ImageNet) and have learned useful
features. You can fine-tune these models for your specific task.
o Custom CNN Architecture (Alternative): If you prefer to build your own
CNN architecture, design a stack of convolutional layers, pooling layers, and
fully connected layers. Ensure that the architecture suits the complexity of your
classification problem.
o Compile the Model: Define the loss function (typically categorical cross-
entropy for classification), the optimizer (e.g., Adam, SGD), and the evaluation
metric (e.g., accuracy).
Step 3: Training the CNN Model
o Training: Feed the training data into the CNN model and start training. During
training, the model adjusts its weights to minimize the loss function. This
process may take several epochs (iterations over the entire dataset). Monitor
training performance on the validation set to prevent overfitting.
Step 4: Evaluate and Fine-Tune
o Validation: After training, evaluate the model's performance on the validation
set. This helps you tune hyperparameters, such as learning rate, batch size, and
model architecture, for better results.
o Fine-Tuning (Optional): Depending on validation results, you may decide to
fine-tune the model by adjusting layers, adding regularization (e.g., dropout), or
training for more epochs.
Step 5: Testing and Deployment
o Testing: Once you are satisfied with the model's performance, evaluate it on the
separate test dataset to assess its generalization to unseen data.
o Deployment: If the model performs well, deploy it in your application for real-
time image classification. This could be in the form of a web app, mobile app, or
integration into an existing system.
o Monitoring and Maintenance: Continuously monitor the model's performance
in the production environment and retrain it periodically with new data if
necessary.
Text Classification
Text classification is the process of categorization text into organised groups.
Text classification becoming an important part of business as it allows us to easily get
insights from data and automatic business process.
The process of text classification typically involves several steps, including text pre-
processing, feature extraction, and machine learning model training.
That means the words which are generally filtered out before processing a natural
language are called Stop-words.
Examples of stop words in English include "the", "a", "an", "and", "in", "of", "to", etc.
Tokenization
It can be also defined as Tokenization is the process of breaking down a piece of
text into smaller units called tokens, which are usually words or sub words.
The tokenization process would break this sentence down into the following
tokens: "The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog".
Kinds Of Tokenization
1. Word Tokenization
2. Character Tokenization
3. Sub-Word Tokenization
Stemming.
Stemming is the process of reducing a word to its base or root form, called a stem,
by removing its suffixes and prefixes or the roots of words known as
"lemmas".
The process of obtaining the root word from the given word is called Stemming.
For example, the word "running" can be stemmed to "run", and the word "cats" can be stemmed
to "cat".
Different Types of frequencies
i. Document Frequency
ii. Global Frequency
iii. Term Frequency
iv. IDF
v. TF-IDF
TF-IDF = TF * IDF
Assignment - 2