**Appendix A**

Program code for supervised CNN model is given below:

*Step#1 Opening Python*

Python was opened, and conda environment was selected.

Sigmoid represents the activation function of this model. *Step#4 Fitting CNN to the Images (Training and Validation)*

train\_datagen = ImageDataGenerator(rescale = 1./255,

*Data Processing Using Artificial Neural Networks DOI: http://dx.doi.org/10.5772/intechopen.91935*

test\_datagen = ImageDataGenerator(rescale = 1./255) training\_set = train\_datagen.flow\_from\_directory('Data/Train',

test\_set = test\_datagen.flow\_from\_directory('Data/Validation',

directories are for the path to the training folder and validation folder

test\_image = image.load\_img('Data/Apple.JPG', target\_size = (150, 150))

Program code for unsupervised SOM model is given below:

Python was opened, and conda environment was selected.

*Step#2 Installing and Import Necessary Data Sources*

shear\_range = 0.2, zoom\_range = 0.2, horizontal\_flip = True)

target\_size = (150, 150), batch\_size = 12, class\_mode = 'binary')

target\_size = (150, 150), batch\_size = 8, class\_mode = 'binary')

steps\_per\_epoch = 10,

validation\_data = test\_set, validation\_steps = 10)

epochs = 4,

model.fit\_generator(training\_set,

*Step#5 Running the ANN Model*

result = model.predict(test\_image) training\_set.class\_indices

if result[0][0] == 1: prediction = 'Orange'

print (prediction)

prediction = 'Apple'

*Step#1 Opening Python*

from minisom import MiniSom

import matplotlib.pyplot as plt

import numpy as np

**101**

else:

**Appendix B**

test\_image = image.img\_to\_array(test\_image) test\_image = np.expand\_dims(test\_image, axis = 0)

*Step#2 Installing and Import Necessary Data Sources*

from keras.preprocessing.image import ImageDataGenerator from keras.models import Sequential from keras.layers import Conv2D, MaxPooling2D from keras.layers import Activation, Dropout, Flatten, Dense from keras import backend as K from keras.preprocessing import image import tensorflow as tf import numpy as np

#### *Step#3 CNN Convolutional Network Model*

```
#Input Layer
model = Sequential()
```

```