Machine Learning
39.2K subscribers
3.83K photos
32 videos
41 files
1.3K links
Machine learning insights, practical tutorials, and clear explanations for beginners and aspiring data scientists. Follow the channel for models, algorithms, coding guides, and real-world ML applications.

Admin: @HusseinSheikho || @Hussein_Sheikho
Download Telegram
Topic: CNN (Convolutional Neural Networks) – Part 1: Introduction and Basic Concepts

---

1. What is a CNN?

• A Convolutional Neural Network (CNN) is a type of deep learning model primarily used for analyzing visual data.

• CNNs automatically learn spatial hierarchies of features through convolutional layers.

---

2. Key Components of CNN

Convolutional Layer: Applies filters (kernels) to input images to extract features like edges, textures, and shapes.

Activation Function: Usually ReLU (Rectified Linear Unit) is applied after convolution for non-linearity.

Pooling Layer: Reduces the spatial size of feature maps, typically using Max Pooling.

Fully Connected Layer: After feature extraction, maps features to output classes.

---

3. How Convolution Works

• A kernel (small matrix) slides over the input image, computing element-wise multiplications and summing them up to form a feature map.

• Kernels detect features like edges, lines, and patterns.

---

4. Basic CNN Architecture Example

| Layer Type | Description |
| --------------- | ---------------------------------- |
| Input | Image of size (e.g., 28x28x1) |
| Conv Layer | 32 filters of size 3x3 |
| Activation | ReLU |
| Pooling Layer | MaxPooling 2x2 |
| Fully Connected | Flatten + Dense for classification |

---

5. Simple CNN with PyTorch Example

import torch.nn as nn
import torch.nn.functional as F

class SimpleCNN(nn.Module):
def __init__(self):
super(SimpleCNN, self).__init__()
self.conv1 = nn.Conv2d(1, 32, kernel_size=3) # 1 input channel, 32 filters
self.pool = nn.MaxPool2d(2, 2)
self.fc1 = nn.Linear(32 * 13 * 13, 10) # Assuming input 28x28

def forward(self, x):
x = self.pool(F.relu(self.conv1(x)))
x = x.view(-1, 32 * 13 * 13) # Flatten
x = self.fc1(x)
return x


---

6. Why CNN over Fully Connected Networks?

• CNNs reduce the number of parameters by weight sharing in kernels.

• They preserve spatial relationships unlike fully connected layers.

---

Summary

• CNNs are powerful for image and video tasks due to convolution and pooling.

• Understanding convolution, pooling, and architecture basics is key to building models.

---

Exercise

• Implement a CNN with two convolutional layers and train it on MNIST digits.

---

#CNN #DeepLearning #NeuralNetworks #Convolution #MachineLearning

https://t.iss.one/DataScience4
8