From a20eaa37ac4a7aca4ef75326aa41a46b4c1fc08a Mon Sep 17 00:00:00 2001 From: Arpit Kumar <137612747+amazingak1@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:32:58 +0530 Subject: [PATCH 1/7] Create Readme.md --- Readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Readme.md diff --git a/Readme.md b/Readme.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/Readme.md @@ -0,0 +1 @@ + From 53c7b11df134c6fdd99438f249468620d0262cea Mon Sep 17 00:00:00 2001 From: Arpit Kumar <137612747+amazingak1@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:48:18 +0530 Subject: [PATCH 2/7] Rename Readme.md to CNN.md --- Readme.md => CNN.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Readme.md => CNN.md (100%) diff --git a/Readme.md b/CNN.md similarity index 100% rename from Readme.md rename to CNN.md From daf484694d78bd52a4d27fa30709c55f2aebbec7 Mon Sep 17 00:00:00 2001 From: Arpit Kumar <137612747+amazingak1@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:32:55 +0530 Subject: [PATCH 3/7] Create CNN.md --- docs/DL/algorithms/CNN.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/DL/algorithms/CNN.md diff --git a/docs/DL/algorithms/CNN.md b/docs/DL/algorithms/CNN.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/docs/DL/algorithms/CNN.md @@ -0,0 +1 @@ + From 795dfce2c21ab6d89b7c206e7e31ae7dae379777 Mon Sep 17 00:00:00 2001 From: Arpit Kumar <137612747+amazingak1@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:39:24 +0530 Subject: [PATCH 4/7] Update CNN.md --- docs/DL/algorithms/CNN.md | 103 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/docs/DL/algorithms/CNN.md b/docs/DL/algorithms/CNN.md index 8b137891..0d8fe245 100644 --- a/docs/DL/algorithms/CNN.md +++ b/docs/DL/algorithms/CNN.md @@ -1 +1,104 @@ +# Convolutional Neural Networks (CNNs) +## Overview +Convolutional Neural Networks (CNNs) are a type of deep learning algorithm specifically designed for processing structured grid data such as images. They are widely used in computer vision tasks like image classification, object detection, and image segmentation. + +--- + +## How CNNs Work + +### 1. **Architecture** +CNNs are composed of the following layers: +- **Convolutional Layers**: Extract spatial features from the input data. +- **Pooling Layers**: Reduce the spatial dimensions of feature maps to lower computational costs. +- **Fully Connected Layers**: Perform high-level reasoning for final predictions. + +### 2. **Key Concepts** +- **Filters (Kernels)**: Small matrices that slide over the input to extract features. +- **Strides**: Step size of the filter movement. +- **Padding**: Adding borders to the input for better filter coverage. +- **Activation Functions**: Introduce non-linearity (e.g., ReLU). + +--- + +## CNN Algorithms + +### 1. **LeNet** +- **Proposed By**: Yann LeCun (1998) +- **Use Case**: Handwritten digit recognition (e.g., MNIST dataset). +- **Architecture**: + - Input → Convolution → Pooling → Convolution → Pooling → Fully Connected → Output + +### 2. **AlexNet** +- **Proposed By**: Alex Krizhevsky (2012) +- **Use Case**: ImageNet classification challenge. +- **Key Features**: + - Uses ReLU for activation. + - Includes dropout to prevent overfitting. + - Designed for GPUs for faster computation. + +### 3. **VGGNet** +- **Proposed By**: Visual Geometry Group (2014) +- **Use Case**: Image classification and transfer learning. +- **Key Features**: + - Uses small 3x3 filters. + - Depth of the network increases (e.g., VGG-16, VGG-19). + +### 4. **ResNet** +- **Proposed By**: Kaiming He et al. (2015) +- **Use Case**: Solving vanishing gradient problems in deep networks. +- **Key Features**: + - Introduces residual blocks with skip connections. + - Enables training of very deep networks (e.g., ResNet-50, ResNet-101). + +### 5. **MobileNet** +- **Proposed By**: Google (2017) +- **Use Case**: Mobile and embedded vision applications. +- **Key Features**: + - Utilizes depthwise separable convolutions. + - Lightweight architecture suitable for mobile devices. + +--- + +## Code Example: Implementing a Simple CNN + +Here’s a Python example of a CNN using **TensorFlow/Keras**: + +```python +from tensorflow.keras.models import Sequential +from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense + +# Build the CNN +model = Sequential([ + Conv2D(32, (3, 3), activation='relu', input_shape=(64, 64, 3)), + MaxPooling2D(pool_size=(2, 2)), + Conv2D(64, (3, 3), activation='relu'), + MaxPooling2D(pool_size=(2, 2)), + Flatten(), + Dense(128, activation='relu'), + Dense(10, activation='softmax') # Replace 10 with the number of classes in your dataset +]) + +# Compile the model +model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy']) + +# Summary +model.summary() +``` + +--- + +# Visualizations +* **Filters and Feature Maps:** Visualizing how the CNN learns features from images. +* **Training Metrics:** Plotting accuracy and loss during training. + +```python +import matplotlib.pyplot as plt + +# Example: Visualizing accuracy and loss +plt.plot(history.history['accuracy'], label='Accuracy') +plt.plot(history.history['val_accuracy'], label='Validation Accuracy') +plt.xlabel('Epochs') +plt.ylabel('Accuracy') +plt.legend() +plt.show() From 23ae579302ee1efe35c2d006a5f9ba8b9cda046b Mon Sep 17 00:00:00 2001 From: Arpit Kumar <137612747+amazingak1@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:43:54 +0530 Subject: [PATCH 5/7] Rename CNN.md to Convolution_neural_network.md --- docs/DL/algorithms/{CNN.md => Convolution_neural_network.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/DL/algorithms/{CNN.md => Convolution_neural_network.md} (100%) diff --git a/docs/DL/algorithms/CNN.md b/docs/DL/algorithms/Convolution_neural_network.md similarity index 100% rename from docs/DL/algorithms/CNN.md rename to docs/DL/algorithms/Convolution_neural_network.md From 792c32aab164a9197a22bd8b7efd7baeee94f3bb Mon Sep 17 00:00:00 2001 From: Arpit Kumar <137612747+amazingak1@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:52:55 +0530 Subject: [PATCH 6/7] Update Convolution_neural_network.md --- docs/DL/algorithms/Convolution_neural_network.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/DL/algorithms/Convolution_neural_network.md b/docs/DL/algorithms/Convolution_neural_network.md index 0d8fe245..04508632 100644 --- a/docs/DL/algorithms/Convolution_neural_network.md +++ b/docs/DL/algorithms/Convolution_neural_network.md @@ -64,6 +64,13 @@ CNNs are composed of the following layers: Here’s a Python example of a CNN using **TensorFlow/Keras**: +* Sequential: Used to stack layers to create a neural network model. +* Conv2D: Implements the convolutional layers to extract features from input images. +* MaxPooling2D: Reduces the size of feature maps while retaining important features. +* Flatten: Converts 2D feature maps into a 1D vector to pass into fully connected layers. +* Dense: Implements fully connected (dense) layers, responsible for decision-making. + + ```python from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense From 6ac0be8710e3a821422f395218b271881b3a54e8 Mon Sep 17 00:00:00 2001 From: Arpit Kumar <137612747+amazingak1@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:54:45 +0530 Subject: [PATCH 7/7] Update Convolution_neural_network.md --- docs/DL/algorithms/Convolution_neural_network.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/DL/algorithms/Convolution_neural_network.md b/docs/DL/algorithms/Convolution_neural_network.md index 04508632..2c440115 100644 --- a/docs/DL/algorithms/Convolution_neural_network.md +++ b/docs/DL/algorithms/Convolution_neural_network.md @@ -64,11 +64,11 @@ CNNs are composed of the following layers: Here’s a Python example of a CNN using **TensorFlow/Keras**: -* Sequential: Used to stack layers to create a neural network model. -* Conv2D: Implements the convolutional layers to extract features from input images. -* MaxPooling2D: Reduces the size of feature maps while retaining important features. -* Flatten: Converts 2D feature maps into a 1D vector to pass into fully connected layers. -* Dense: Implements fully connected (dense) layers, responsible for decision-making. +* **Sequential:** Used to stack layers to create a neural network model. +* **Conv2D:** Implements the convolutional layers to extract features from input images. +* **MaxPooling2D:** Reduces the size of feature maps while retaining important features. +* **Flatten:** Converts 2D feature maps into a 1D vector to pass into fully connected layers. +* **Dense:** Implements fully connected (dense) layers, responsible for decision-making. ```python