<jupyter_start><jupyter_text>Convolution Neural Networks<jupyter_code>#keras - prepare a structure for the datasets

#building the cnn
#intitalizing the cnn

classifier = Sequential()
#importing the libraries
from keras.models import Sequential
from keras.layers import Conv2D
from keras.layers import MaxPool2D
from keras.layers import Flatten
from keras.layers import Dense
#convolution layer

classifier.add(Conv2D(filters=32,kernel_size= (3,3), input_shape = (64,64,3),
                      data_format="channels_last", activation = "relu"))
#max pooling

classifier.add(MaxPool2D(pool_size=(2,2)))
classifier.add(Flatten())
classifier.add(Dense(units= 128, activation="relu"))
classifier.add(Dense(units = 1, activation="sigmoid"))
classifier.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
#Fitting the cnn to the images

from keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator(
        rescale=1./255,
        shear_range=0.2,
        zoom_range=0.2,
        horizontal_flip=True)
test_datagen = ImageDataGenerator(rescale=1./255)
training_set = train_datagen.flow_from_directory(
        'dataset/training_set',
        target_size=(64, 64),
        batch_size=32,
        class_mode='binary')
test_set = test_datagen.flow_from_directory(
        'dataset/test_set',
        target_size=(64, 64),
        batch_size=32,
        class_mode='binary')
#fitting the data
classifier.fit_generator(
        training_set,
        steps_per_epoch=8000,
        epochs=20,
        validation_data=test_set,
        validation_steps=2000, verbose = 2,use_multiprocessing=False,workers = 6)
2+2<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1055753262158956, 'fraction_numerical': 0.033807829181494664, 'mean_word_length': 4.5130718954248366, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '147858', 'license': 'MIT', 'n_tokens_mistral': 581, 'n_tokens_neox': 547, 'n_words': 107, 'path': 'Volume 1 - Supervised Deep Learning/Part 2 - CNN/Section 8 - Building a CNN/CNN.ipynb', 'repo_name': 'Niranjankumar-c/DeepLearning_A-Z_NeuralNetworks_Python', 'size': '1686'}