Hi developers!!I hope you are doing good, do you want to implement a perfect CNN MODEL using Matlab? if so let's start

To get the best training you need to use some metrics.

First, we start by loading data to treat it.

There are different ways to code this instruction but in my experience, I recommended easily using the imagedatastore function

Use an ImageDatastore object to manage a collection of image files, where each individual image fits in memory, but the entire collection of images does not necessarily fit. You can create an ImageDatastore object using the imageDatastore function, specify its properties, and then import and process the data using object functions.

This function is not available in the Anciennes Matlab versions, so if you want to use it for example in Matlab 2015 as I did your model will never work,it can be work just in Matlab 2018 >=

There are two ways :

imds = imageDatastore(location)

imds = imageDatastore(location,Name,Value)

I recommend the second method because you can specify additional parameters and properties for imds using one or more name-value pair arguments.

Sometimes you meet problems with mentioning the correct location of data that you want to treat since this problem provokes stupid bugs.

To avoid this, When you create your object with the *imagedatastore* function use the parameter *IncludeSubfolders*Specify *true* to include all files and subfolders within each folder or false to include only the files within each folder.

If your model contains several categories to process, you must keep all the Folder at the same size to build perfect and balanced learning.

At the bigining, You need to count the number of data in each category and here the object imds created by the imagedatastore function help you to manage your data,

Then you need to know which category contains the minimum of data and fix them all at her size

After you had been done the pretreatment of your data you need to divide each category into two broad section

70% for Leaining

30% for Teste

Scientists strongly recommend dividing the data into two sub-blocks *Training and Testing* because this choice gives better results than splitting the data into 3 sub-blocks *learning, testing, and validating*.

Also, the scientists suggest "1e-4" as the best rate value in reason it gives good learning for your model

After you had been saved your network you will need to discuss your treatment result for this reason I suggest you use the confusion matrix as the best way to display and compare your training results

I hope my article has brought some knowledge to you on how you can implement a perfect CNN model

]]>Hello my amazing reader , We all know that Artificial intelligence still going strong this last decates ,Deep Learning and specifically covolution neural network in short convnet.

This subject that we will treat in this article in the reason is the most famous and popular architecture used by the developer.

CNN is a deep neural network it works in the same our visuel cortex works and recognizes images .

To get this model from scratch ,We start by presenting its basic architecture As you see in the picture , We can devide the entire architecture into two broad section

feature learning and classification .

So at the first the input image enters into the feature extraction network Then the extracted feature signals enter the clssification neural network to generate the output

The piles of convolution layer and pooling layer pairs

The convolution layer converts the images using the convolution operation which is a collection of digital filters.

The pooling layer combines the neighboring pixels into a signale pixel .

It means that the pooling layer reduces the dimension of the image .

The convolutional layer generates feater maps from images ,It contains filters (covolutional filters ) that converts images .Where the number of the feature map and the convolutional filter is the same .The filter of convolution layer are two dimentional matrices

We have here 4*4 pixel image and one convolution filter

This concept starts by applying the upper left corner of the sub matrix

1*1+0*1+4*0+6*1 = 7

And the output of this addition presents the block (upper left corner) The next convolution will be applied to this block

1*1+1*0+0*6+1*4=5

This process will keep going and the final result is presented in the picture , So the 4*4 pixel image has been converted to 3*3 pixel image

As we see in the picture there is another layer convolution filter and feature map These are the activation function They are the same as those we use in neural network

Is the most popular activation function

The task of the pooling layer is to reduce the size of the imageIts operation is very easyThere are two types of pooling max pooling and mean pooling

For the mean pooling, the convolution is done by taking the means of the convolution areas** Exp** :(1+1+4+6)/4=3(1+3+4+8)/4= 4

In the same way for the next areas

We take the largest value of each of the convolution areas

I first gathered this packet of information when I did my thesis, and this foundation has clarified and made my coding journey easy and meaningful good luck to everyone .

]]>In this article, I will further explain the concept of pointers (data structure) with some examples to practice what we have mentioned in the last article(part 1).To understand this concept you should check first the article Parte one and welcome back to train with me.

We assume that we have a class of 50 students and each person is defined by:

- His code,
- His family name [ max = 20 character];
- His name [ max = 20 character];

- Method One :(2+20+20)*50 =2100 bytes

Since we use here *static variables*,So if we need to calculate the memory area for one student is always equal to the storage space for 50 students, so the result will be always 2100 bytes

*While the second method, the mechanism is different*

S= 50+(2+20+20)*20 = 8900 bytes

Since we use here pointers we consume just the requested memory size, 50: Is the size of the pointer array, since they announced that each pointer occupies one byte

Waste and mismanagement of data since static variables occupy memory until the end of execution.

Better optimization of memory space since dynamic variables can be created and deleted at any time

the C language allows us to compare pointers using

== , != ,< ,>,<=,>= , null

We suppose T is an array of integers and P is a pointer to an integer

These are the most popular instructions that you will need to use pointers and to build a solid basis in this domain I hope that you found my article useful, I did my best to clarify the idea and present it in a simple way

]]>