Convolutional Neural Network
A type of neural network
Typically used on pictures
Depiction of a CNN
How to code a CNN
Analysis of the Structure
It can be seen that ReLu is used in this network along with softmax.
Pooling maps a region of an image in order to identify different features of an image.
Softmax is used to identify the probability of what this image is (logistic regression)
1. Import any needed libraries
2. Import all training and testing images
3. Reshape any needed arrays or clean the needed data:
4. If needed, convert each image to a float between 0 and 225 and then between a 0-1 (in python colors are identified as three numbers all varying from 0 to 225):
5. Convert the Y values to categorical values (similar to one hot encoding)
6. Create the network, add ReLu layers, and the final softmax layers
7. Compile the network
8. Train the model and print the results
9. Set an array of what the CNN predicted for each image (this isn’t required but is just interesting to look at).
Note: Predict_proba returns the probability estimate (softmax)
Predict_classes returns what actual value/category the model returned