Posts

Showing posts from September, 2024

What are Convolutions?

Image
Introduction After writing my article over how to build a CNN, I forgot that I should've explained what a convolution is, in terms of image recognition.  What are Convolutions? They are essentially manners of seeing the probability of a distinct set of figures. Suppose we have 2 lists,  ["parrot","dog","cat"] ;  ["bagel","bread","cheese"] What is the probability of getting a bagel?  (3/9, or ~33%) What is the probability of getting a cat or a bagel?  (5/9, or ~56%) This is what a convolution tries to do.  In the context of image generation, we use a kernel, a matrix to look over every pixel (if you decide to keep it that way) of the image with certain values. The kernel will scan every pixel and then form a new matrice constructed with the scan of the pixels that want to be highlighted.    (It's the number 2) There is also this thing called stride when it comes to kernels. Stride is used to tell the kernel how many pix...

Using PyTorch to create a Convolutional Neural Network for Image Classification of Numbers

Image
Introduction Just a few notes before I get started: 1) Be on the lookout for overfitting in your models. Do not use to many layers, because when you eventually test it, it will be so tuned so much to your trained dataset that it will actually provide the wrong answer during your test (personal experience). 2) .to('cuda') vs .to('cpu'): if you have a compatible NVDIA graphics card with the CUDA drivers downloaded, you should check if you can use this function before proceeding with my code. If you don't have an NVDIA graphics card or don't want to, you can use ".to('cpu')" to use your CPU instead. 3) I am using the MNIST Number Dataset on Google Colab with a T4 GPU and have tested it on a RTX 3060. You can use ".to('cuda')" for either. Framing + Implementation  Our goal is to get the computer to understand integers 0-9. To do this, we will use a Convolutional Neural Network. Personally, I will be using the PyTorch library to ac...