<jupyter_start><jupyter_text>Import the necessary packages<jupyter_code>import keras<jupyter_output><empty_output><jupyter_text>Import keras dataset which is cifar10<jupyter_code>from keras.datasets import cifar10<jupyter_output><empty_output><jupyter_text>Load the dataset<jupyter_code>(x_train,y_train),(x_test,y_test)=cifar10.load_data()<jupyter_output>Downloading data from https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
170500096/170498071 [==============================] - 6s 0us/step<jupyter_text>Get x_train, x_test, y_train and y_test<jupyter_code>x_train=x_train.astype('float32')
x_test=x_test.astype('float32')
x_train=x_train/255.0
x_test=x_test/255.0<jupyter_output><empty_output><jupyter_text>Get y_train and y_test as one-hot encoding<jupyter_code>from keras.utils import np_utils
y_train = np_utils.to_categorical(y_train)
y_test = np_utils.to_categorical(y_test)<jupyter_output><empty_output><jupyter_text>Keras Funcational CNN model<jupyter_code>from keras.layers import Input
input_img=Input(shape=(32,32,3))<jupyter_output><empty_output><jupyter_text>**Now, we feed the input tensor to each of the 1x1, 3x3, 5x5 filters in the inception module.**<jupyter_code>from keras.layers import Conv2D, MaxPooling2D
tower_1 = Conv2D(64, (1,1), padding='same', activation='relu')(input_img)
tower_1 = Conv2D(64, (3,3), padding='same', activation='relu')(tower_1)

tower_2 = Conv2D(64, (1,1), padding='same', activation='relu')(input_img)
tower_2 = Conv2D(64, (5,5), padding='same', activation='relu')(tower_2)

tower_3 = MaxPooling2D((3,3), strides=(1,1), padding='same')(input_img)
tower_3 = Conv2D(64, (1,1), padding='same', activation='relu')(tower_3)
import keras
output = keras.layers.concatenate([tower_1, tower_2, tower_3], axis = 3)
from keras.layers import Flatten,Dense
output=Flatten()(output)
out=Dense(10,activation='softmax')(output)<jupyter_output><empty_output><jupyter_text>Print the summary of the model<jupyter_code>from keras.models import Model
model=Model(inputs=input_img,outputs=out)
model.summary()<jupyter_output>Model: "model_7"
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_3 (InputLayer)            (None, 32, 32, 3)    0                                            
__________________________________________________________________________________________________
conv2d_11 (Conv2D)              (None, 32, 32, 64)   256         input_3[0][0]                    
__________________________________________________________________________________________________
conv2d_13 (Conv2D)              (None, 32, 32, 64)   256         input_3[0][0]                    
__________________________________________________________________________________________________
max_pooling2d_3 (MaxPooling2D)  (None, 32, 32, 3)    0           input_3[0][0]              [...]<jupyter_text>Compile and fit our model<jupyter_code>from keras.optimizers import SGD
epochs = 10
lrate = 0.01
decay = lrate/epochs
sgd = SGD(lr=lrate, momentum=0.9, decay=decay, nesterov=False)
model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])
model.fit(x_train, y_train, validation_split=0.1, epochs=epochs, batch_size=32)<jupyter_output>WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/math_grad.py:1424: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:1033: The name tf.assign_add is deprecated. Please use tf.compat.v1.assign_add instead.

WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:1020: The name tf.assign is deprecated. Please use tf.compat.v1.assign instead.

WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:3005: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

Train on 45000 samples, validate on 5000 samples
Epoch 1/10
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow[...]<jupyter_text>Model Visualization<jupyter_code>from keras.utils import plot_model
plot_model(model, to_file='model.png', show_shapes=True, show_layer_names=True)<jupyter_output><empty_output><jupyter_text>Printing the accuracy of our model<jupyter_code>scores = model.evaluate(x_test, y_test, verbose=0)
print("Accuracy:{0}" .format(scores[1]*100))<jupyter_output>Accuracy:63.2
{'fraction_non_alphanumeric': 0.13775933609958507, 'fraction_numerical': 0.04419087136929461, 'mean_word_length': 6.249624060150376, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '225557', 'license': 'Apache-2.0', 'n_tokens_mistral': 1713, 'n_tokens_neox': 1585, 'n_words': 281, 'path': 'Single_unit_structure_of_Inception_Model.ipynb', 'repo_name': 'umar-ali-k/CNN-models', 'size': '4820'}