0% found this document useful (0 votes)
17 views

DL 8

Uploaded by

Siddesh Pingale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

DL 8

Uploaded by

Siddesh Pingale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

24/04/2024, 13:39 CIFAR-100-Image-Classification-using-ResNet/CIFAR_100_Classification_NN_Project.ipynb at main · SuyashShetty16/CIF… 24/04/2024, 13:39 CIFAR-100-Image-Classification-using-ResNet/CIFAR_100_Classification_NN_Project.

ipynb at main · SuyashShetty16/CIF…

Importing Libraries
In [28]: import tensorflow as tf
from tensorflow.keras import layers, models
In [5]: # Normalize pixel values to be between 0 and 1
from tensorflow.keras.datasets import cifar100
from tensorflow.keras.utils import to_categorical x_train, x_test = x_train / 255.0, x_test / 255.0
from tensorflow.keras.preprocessing.image import ImageDataGenerator

import matplotlib.pyplot as plt Adding augmentation


import numpy as np
from google.colab import drive
In [6]: datagen = ImageDataGenerator(
import random
rotation_range=20,
width_shift_range=0.2,
height_shift_range=0.2,
Loading CIFAR-100 dataset )
horizontal_flip=True

In [3]: (x_train, y_train), (x_test, y_test) = cifar100.load_data() datagen.fit(x_train)

Downloading data from https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.


In [7]: # Convert class vectors to binary class matrices
gz
169001437/169001437 [==============================] - 13s 0us/step num_classes = 100
y_train = to_categorical(y_train, num_classes)
In [4]: class_names = [ y_test = to_categorical(y_test, num_classes)
'apple', 'aquarium_fish', 'baby', 'bear', 'beaver', 'bed', 'bee', 'beet
'bowl', 'boy', 'bridge', 'bus', 'butterfly', 'camel', 'can', 'castle',
'chair', 'chimpanzee', 'clock', 'cloud', 'cockroach', 'couch', 'crab',
'dolphin', 'elephant', 'flatfish', 'forest', 'fox', 'girl', 'hamster', Building Model Architecture
'lamp', 'lawn_mower', 'leopard', 'lion', 'lizard', 'lobster', 'man', 'm
'mouse', 'mushroom', 'oak_tree', 'orange', 'orchid', 'otter', 'palm_tr In [8]:
'plain', 'plate', 'poppy', 'porcupine', 'possum', 'rabbit', 'raccoon', def resnet_block(x, filters, kernel_size=3, stride=1, conv_shortcut=True):
'seal', 'shark', 'shrew', 'skunk', 'skyscraper', 'snail', 'snake', 'sp shortcut = x
'sweet_pepper', 'table', 'tank', 'telephone', 'television', 'tiger', 't if conv_shortcut:
'wardrobe', 'whale', 'willow_tree', 'wolf', 'woman', 'worm' shortcut = layers.Conv2D(filters, 1, strides=stride, padding='same
] shortcut = layers.BatchNormalization()(shortcut)

# Display some example images x = layers.Conv2D(filters, kernel_size, strides=stride, padding='same'


plt.figure(figsize=(10, 5)) x = layers.BatchNormalization()(x)
for i in range(10): x = layers.Activation('relu')(x)
plt.subplot(2, 5, i + 1)
plt.imshow(x_train[i]) x = layers.Conv2D(filters, kernel_size, padding='same')(x)
plt.title(class_names[int(y_train[i])]) x = layers.BatchNormalization()(x)
plt.axis('off')
x = layers.add([x, shortcut])
plt.show() x = layers.Activation('relu')(x)
return x

def modifyNet(input_shape, num_classes=100, num_blocks_list=[2, 2, 2, 2],


inputs = tf.keras.Input(shape=input_shape)

x = layers.Conv2D(128, 3, strides=1, padding='same')(inputs)


x = layers.BatchNormalization()(x)
x = layers.Activation('relu')(x)

# Adding Dropout layer after the first set of residual blocks


x = layers.Dropout(dropout_rate)(x)

https://github.com/SuyashShetty16/CIFAR-100-Image-Classification-using-ResNet/blob/main/CIFAR_100_Classification_NN_Project.ipynb 2/12 https://github.com/SuyashShetty16/CIFAR-100-Image-Classification-using-ResNet/blob/main/CIFAR_100_Classification_NN_Project.ipynb 3/12


24/04/2024, 13:39 CIFAR-100-Image-Classification-using-ResNet/CIFAR_100_Classification_NN_Project.ipynb at main · SuyashShetty16/CIF… 24/04/2024, 13:39 CIFAR-100-Image-Classification-using-ResNet/CIFAR_100_Classification_NN_Project.ipynb at main · SuyashShetty16/CIF…

for i, num_blocks in enumerate(num_blocks_list): ]


for j in range(num_blocks):
strides = 2 if i > 0 and j == 0 else 1 conv2d_3 (Conv2D) (None, 32, 32, 128) 147584 ['activa
x = resnet_block(x, 128 * 2**i, stride=strides) tion_1[0][0]']

x = layers.GlobalAveragePooling2D()(x) conv2d_1 (Conv2D) (None, 32, 32, 128) 16512 ['dropou


t[0][0]']
x = layers.Dense(num_classes, activation='softmax')(x)

batch_normalization_3 (Bat (None, 32, 32, 128) 512 ['conv2d


model = models.Model(inputs, x)
_3[0][0]']
return model
chNormalization)

batch_normalization_1 (Bat (None, 32, 32, 128) 512 ['conv2d


_1[0][0]']
In [9]: input_shape = x_train.shape[1:] chNormalization)
model = modifyNet(input_shape, num_classes)
add (Add) (None, 32, 32, 128) 0 ['batch_
normalization_3[0][0]'
, 'batch
Compiling the model _normalization_1[0][0]
']

In [10]: model.compile(optimizer='adam', activation_2 (Activation) (None, 32, 32, 128) 0 ['add[0]


loss='categorical_crossentropy', [0]']
metrics=['accuracy'])
conv2d_5 (Conv2D) (None, 32, 32, 128) 147584 ['activa
tion_2[0][0]']

batch_normalization_5 (Bat (None, 32, 32, 128) 512 ['conv2d


Displaing model summary _5[0][0]']
chNormalization)
In [11]: model.summary()
activation_3 (Activation) (None, 32, 32, 128) 0 ['batch_
normalization_5[0][0]'
Model: "model"
]
____________________________________________________________________________
______________________
conv2d_6 (Conv2D) (None, 32, 32, 128) 147584 ['activa
Layer (type) Output Shape Param # Connecte
tion_3[0][0]']
d to
============================================================================
conv2d_4 (Conv2D) (None, 32, 32, 128) 16512 ['activa
======================
tion_2[0][0]']
input_1 (InputLayer) [(None, 32, 32, 3)] 0 []
batch_normalization_6 (Bat (None, 32, 32, 128) 512 ['conv2d
conv2d (Conv2D) (None, 32, 32, 128) 3584 ['input_
_6[0][0]']
1[0][0]']
chNormalization)
batch_normalization (Batch (None, 32, 32, 128) 512 ['conv2d
batch_normalization_4 (Bat (None, 32, 32, 128) 512 ['conv2d
[0][0]']
_4[0][0]']
Normalization)
chNormalization)
activation (Activation) (None, 32, 32, 128) 0 ['batch_
add_1 (Add) (None, 32, 32, 128) 0 ['batch_
normalization[0][0]']
normalization_6[0][0]'
, 'batch
dropout (Dropout) (None, 32, 32, 128) 0 ['activa
_normalization_4[0][0]
tion[0][0]']
']
conv2d_2 (Conv2D) (None, 32, 32, 128) 147584 ['dropou
activation_4 (Activation) (None, 32, 32, 128) 0 ['add_1
t[0][0]']
[0][0]']
batch_normalization_2 (Bat (None, 32, 32, 128) 512 ['conv2d
conv2d_8 (Conv2D) (None, 16, 16, 256) 295168 ['activa
_2[0][0]']
tion_4[0][0]']
chNormalization)
batch_normalization_8 (Bat (None, 16, 16, 256) 1024 ['conv2d
activation_1 (Activation) (None, 32, 32, 128) 0 ['batch_
_8[0][0]']
normalization_2[0][0]'
chNormalization)
https://github.com/SuyashShetty16/CIFAR-100-Image-Classification-using-ResNet/blob/main/CIFAR_100_Classification_NN_Project.ipynb 4/12 https://github.com/SuyashShetty16/CIFAR-100-Image-Classification-using-ResNet/blob/main/CIFAR_100_Classification_NN_Project.ipynb 5/12
24/04/2024, 13:39 CIFAR-100-Image-Classification-using-ResNet/CIFAR_100_Classification_NN_Project.ipynb at main · SuyashShetty16/CIF… 24/04/2024, 13:39 CIFAR-100-Image-Classification-using-ResNet/CIFAR_100_Classification_NN_Project.ipynb at main · SuyashShetty16/CIF…
chNormalization)
tion_8[0][0]']
activation_5 (Activation) (None, 16, 16, 256) 0 ['batch_
batch_normalization_14 (Ba (None, 8, 8, 512) 2048 ['conv2d
normalization_8[0][0]'
_14[0][0]']
]
tchNormalization)
conv2d_9 (Conv2D) (None, 16, 16, 256) 590080 ['activa
activation_9 (Activation) (None, 8, 8, 512) 0 ['batch_
tion_5[0][0]']
normalization_14[0][0]
']
conv2d_7 (Conv2D) (None, 16, 16, 256) 33024 ['activa
tion_4[0][0]']
conv2d_15 (Conv2D) (None, 8, 8, 512) 2359808 ['activa
tion_9[0][0]']
batch_normalization_9 (Bat (None, 16, 16, 256) 1024 ['conv2d
_9[0][0]']
conv2d_13 (Conv2D) (None, 8, 8, 512) 131584 ['activa
chNormalization)
tion_8[0][0]']
batch_normalization_7 (Bat (None, 16, 16, 256) 1024 ['conv2d
batch_normalization_15 (Ba (None, 8, 8, 512) 2048 ['conv2d
_7[0][0]']
_15[0][0]']
chNormalization)
tchNormalization)
add_2 (Add) (None, 16, 16, 256) 0 ['batch_
batch_normalization_13 (Ba (None, 8, 8, 512) 2048 ['conv2d
normalization_9[0][0]'
_13[0][0]']
, 'batch
tchNormalization)
_normalization_7[0][0]
']
add_4 (Add) (None, 8, 8, 512) 0 ['batch_
normalization_15[0][0]
activation_6 (Activation) (None, 16, 16, 256) 0 ['add_2
',
[0][0]']
'batch_
normalization_13[0][0]
conv2d_11 (Conv2D) (None, 16, 16, 256) 590080 ['activa
']
tion_6[0][0]']
activation_10 (Activation) (None, 8, 8, 512) 0 ['add_4
batch_normalization_11 (Ba (None, 16, 16, 256) 1024 ['conv2d
[0][0]']
_11[0][0]']
tchNormalization)
conv2d_17 (Conv2D) (None, 8, 8, 512) 2359808 ['activa
tion_10[0][0]']
activation_7 (Activation) (None, 16, 16, 256) 0 ['batch_
normalization_11[0][0]
batch_normalization_17 (Ba (None, 8, 8, 512) 2048 ['conv2d
']
_17[0][0]']
tchNormalization)
conv2d_12 (Conv2D) (None, 16, 16, 256) 590080 ['activa
tion_7[0][0]']
activation_11 (Activation) (None, 8, 8, 512) 0 ['batch_
normalization_17[0][0]
conv2d_10 (Conv2D) (None, 16, 16, 256) 65792 ['activa
']
tion_6[0][0]']
conv2d_18 (Conv2D) (None, 8, 8, 512) 2359808 ['activa
batch_normalization_12 (Ba (None, 16, 16, 256) 1024 ['conv2d
tion_11[0][0]']
_12[0][0]']
tchNormalization)
conv2d_16 (Conv2D) (None, 8, 8, 512) 262656 ['activa
tion_10[0][0]']
batch_normalization_10 (Ba (None, 16, 16, 256) 1024 ['conv2d
_10[0][0]']
batch_normalization_18 (Ba (None, 8, 8, 512) 2048 ['conv2d
tchNormalization)
_18[0][0]']
tchNormalization)
add_3 (Add) (None, 16, 16, 256) 0 ['batch_
normalization_12[0][0]
batch_normalization_16 (Ba (None, 8, 8, 512) 2048 ['conv2d
',
_16[0][0]']
'batch_
tchNormalization)
normalization_10[0][0]
']
add_5 (Add) (None, 8, 8, 512) 0 ['batch_
normalization_18[0][0]
activation_8 (Activation) (None, 16, 16, 256) 0 ['add_3
',
[0][0]']
'batch_
normalization_16[0][0]
conv2d_14 (Conv2D) (None, 8, 8, 512) 1180160 ['activa
']
https://github.com/SuyashShetty16/CIFAR-100-Image-Classification-using-ResNet/blob/main/CIFAR_100_Classification_NN_Project.ipynb 6/12 https://github.com/SuyashShetty16/CIFAR-100-Image-Classification-using-ResNet/blob/main/CIFAR_100_Classification_NN_Project.ipynb 7/12
24/04/2024, 13:39 CIFAR-100-Image-Classification-using-ResNet/CIFAR_100_Classification_NN_Project.ipynb at main · SuyashShetty16/CIF… 24/04/2024, 13:39 CIFAR-100-Image-Classification-using-ResNet/CIFAR_100_Classification_NN_Project.ipynb at main · SuyashShetty16/CIF…
]
add_7 (Add) (None, 4, 4, 1024) 0 ['batch_
normalization_24[0][0]
activation_12 (Activation) (None, 8, 8, 512) 0 ['add_5
',
[0][0]']
'batch_
normalization_22[0][0]
conv2d_20 (Conv2D) (None, 4, 4, 1024) 4719616 ['activa
']
tion_12[0][0]']
activation_16 (Activation) (None, 4, 4, 1024) 0 ['add_7
batch_normalization_20 (Ba (None, 4, 4, 1024) 4096 ['conv2d
[0][0]']
_20[0][0]']
tchNormalization)
global_average_pooling2d ( (None, 1024) 0 ['activa
tion_16[0][0]']
activation_13 (Activation) (None, 4, 4, 1024) 0 ['batch_
GlobalAveragePooling2D)
normalization_20[0][0]
']
dense (Dense) (None, 100) 102500 ['global
_average_pooling2d[0][
conv2d_21 (Conv2D) (None, 4, 4, 1024) 9438208 ['activa
0]']
tion_13[0][0]']
============================================================================
conv2d_19 (Conv2D) (None, 4, 4, 1024) 525312 ['activa
======================
tion_12[0][0]']
Total params: 46203236 (176.25 MB)
Trainable params: 46179940 (176.16 MB)
batch_normalization_21 (Ba (None, 4, 4, 1024) 4096 ['conv2d
Non-trainable params: 23296 (91.00 KB)
_21[0][0]']
____________________________________________________________________________
tchNormalization)
______________________
batch_normalization_19 (Ba (None, 4, 4, 1024) 4096 ['conv2d

Training the model


_19[0][0]']
tchNormalization)

add_6 (Add) (None, 4, 4, 1024) 0 ['batch_


normalization_21[0][0] In [12]: epochs = 30
', batch_size = 64
'batch_ history = model.fit(datagen.flow(x_train, y_train, batch_size=batch_size),
normalization_19[0][0]
']
Epoch 1/30
activation_14 (Activation) (None, 4, 4, 1024) 0 ['add_6
782/782 [==============================] - 210s 235ms/step - loss: 4.0028 -
[0][0]']
accuracy: 0.0882
Epoch 2/30
conv2d_23 (Conv2D) (None, 4, 4, 1024) 9438208 ['activa
782/782 [==============================] - 182s 233ms/step - loss: 3.3806 -
tion_14[0][0]']
accuracy: 0.1770
Epoch 3/30
batch_normalization_23 (Ba (None, 4, 4, 1024) 4096 ['conv2d
782/782 [==============================] - 182s 233ms/step - loss: 2.9296 -
_23[0][0]']
accuracy: 0.2625
tchNormalization)
Epoch 4/30
782/782 [==============================] - 183s 234ms/step - loss: 2.5648 -
activation_15 (Activation) (None, 4, 4, 1024) 0 ['batch_
accuracy: 0.3309
normalization_23[0][0]
Epoch 5/30
']
782/782 [==============================] - 183s 233ms/step - loss: 2.2835 -
accuracy: 0.3935
conv2d_24 (Conv2D) (None, 4, 4, 1024) 9438208 ['activa
Epoch 6/30
tion_15[0][0]']
782/782 [==============================] - 183s 234ms/step - loss: 2.0570 -
accuracy: 0.4430
conv2d_22 (Conv2D) (None, 4, 4, 1024) 1049600 ['activa
Epoch 7/30
tion_14[0][0]']
782/782 [==============================] - 182s 233ms/step - loss: 1.8709 -
accuracy: 0.4854
batch_normalization_24 (Ba (None, 4, 4, 1024) 4096 ['conv2d
Epoch 8/30
_24[0][0]']
782/782 [==============================] - 183s 233ms/step - loss: 1.7212 -
tchNormalization)
accuracy: 0.5239
Epoch 9/30
batch_normalization_22 (Ba (None, 4, 4, 1024) 4096 ['conv2d
782/782 [==============================] - 183s 233ms/step - loss: 1.5798 -
_22[0][0]']
accuracy: 0.5547
tchNormalization)
Epoch 10/30
782/782 [==============================] 183s 234ms/step loss: 1 4540
https://github.com/SuyashShetty16/CIFAR-100-Image-Classification-using-ResNet/blob/main/CIFAR_100_Classification_NN_Project.ipynb 8/12 https://github.com/SuyashShetty16/CIFAR-100-Image-Classification-using-ResNet/blob/main/CIFAR_100_Classification_NN_Project.ipynb 9/12
24/04/2024, 13:39 CIFAR-100-Image-Classification-using-ResNet/CIFAR_100_Classification_NN_Project.ipynb at main · SuyashShetty16/CIF… 24/04/2024, 13:39 CIFAR-100-Image-Classification-using-ResNet/CIFAR_100_Classification_NN_Project.ipynb at main · SuyashShetty16/CIF…
782/782 [==============================] - 183s 234ms/step - loss: 1.4540 -
accuracy: 0.5868
Epoch 11/30 In [30]: model.fit(datagen.flow(x_train, y_train, batch_size=batch_size), epochs=20
782/782 [==============================] - 182s 233ms/step - loss: 1.3500 -
accuracy: 0.6131
Epoch 12/30 Epoch 1/20
782/782 [==============================] - 182s 233ms/step - loss: 1.2491 - 782/782 [==============================] - 183s 234ms/step - loss: 0.2709 -
accuracy: 0.6360 accuracy: 0.9123
Epoch 13/30 Epoch 2/20
782/782 [==============================] - 183s 234ms/step - loss: 1.1551 - 782/782 [==============================] - 183s 234ms/step - loss: 0.2576 -
accuracy: 0.6615 accuracy: 0.9155
Epoch 14/30 Epoch 3/20
782/782 [==============================] - 182s 233ms/step - loss: 1.0652 - 782/782 [==============================] - 183s 234ms/step - loss: 0.2506 -
accuracy: 0.6831 accuracy: 0.9186
Epoch 15/30 Epoch 4/20
782/782 [==============================] - 182s 233ms/step - loss: 0.9936 - 782/782 [==============================] - 183s 233ms/step - loss: 0.2301 -
accuracy: 0.7047 accuracy: 0.9245
Epoch 16/30 Epoch 5/20
782/782 [==============================] - 183s 234ms/step - loss: 0.9134 - 782/782 [==============================] - 182s 233ms/step - loss: 0.2141 -
accuracy: 0.7263 accuracy: 0.9290
Epoch 17/30 Epoch 6/20
782/782 [==============================] - 182s 233ms/step - loss: 0.8404 - 782/782 [==============================] - 183s 233ms/step - loss: 0.2093 -
accuracy: 0.7432 accuracy: 0.9319
Epoch 18/30 Epoch 7/20
782/782 [==============================] - 183s 233ms/step - loss: 0.7688 - 782/782 [==============================] - 183s 234ms/step - loss: 0.1979 -
accuracy: 0.7649 accuracy: 0.9357
Epoch 19/30 Epoch 8/20
782/782 [==============================] - 183s 233ms/step - loss: 0.7011 - 782/782 [==============================] - 183s 234ms/step - loss: 0.1922 -
accuracy: 0.7829 accuracy: 0.9374
Epoch 20/30 Epoch 9/20
782/782 [==============================] - 183s 233ms/step - loss: 0.6448 - 782/782 [==============================] - 183s 233ms/step - loss: 0.1865 -
accuracy: 0.7996 accuracy: 0.9396
Epoch 21/30 Epoch 10/20
782/782 [==============================] - 182s 233ms/step - loss: 0.5890 - 782/782 [==============================] - 182s 233ms/step - loss: 0.1773 -
accuracy: 0.8124 accuracy: 0.9433
Epoch 22/30 Epoch 11/20
782/782 [==============================] - 182s 233ms/step - loss: 0.5419 - 782/782 [==============================] - 183s 233ms/step - loss: 0.1645 -
accuracy: 0.8281 accuracy: 0.9479
Epoch 23/30 Epoch 12/20
782/782 [==============================] - 183s 233ms/step - loss: 0.4955 - 782/782 [==============================] - 182s 233ms/step - loss: 0.1609 -
accuracy: 0.8422 accuracy: 0.9482
Epoch 24/30 Epoch 13/20
782/782 [==============================] - 182s 233ms/step - loss: 0.4457 - 782/782 [==============================] - 182s 233ms/step - loss: 0.1621 -
accuracy: 0.8557 accuracy: 0.9468
Epoch 25/30 Epoch 14/20
782/782 [==============================] - 182s 233ms/step - loss: 0.4053 - 782/782 [==============================] - 183s 233ms/step - loss: 0.1592 -
accuracy: 0.8687 accuracy: 0.9480
Epoch 26/30 Epoch 15/20
782/782 [==============================] - 183s 233ms/step - loss: 0.3828 - 782/782 [==============================] - 182s 233ms/step - loss: 0.1445 -
accuracy: 0.8776 accuracy: 0.9536
Epoch 27/30 Epoch 16/20
782/782 [==============================] - 183s 233ms/step - loss: 0.3505 - 782/782 [==============================] - 182s 233ms/step - loss: 0.1465 -
accuracy: 0.8867 accuracy: 0.9538
Epoch 28/30 Epoch 17/20
782/782 [==============================] - 182s 233ms/step - loss: 0.3352 - 782/782 [==============================] - 182s 233ms/step - loss: 0.1413 -
accuracy: 0.8912 accuracy: 0.9538
Epoch 29/30 Epoch 18/20
782/782 [==============================] - 183s 233ms/step - loss: 0.3068 - 782/782 [==============================] - 183s 234ms/step - loss: 0.1363 -
accuracy: 0.9016 accuracy: 0.9567
Epoch 30/30 Epoch 19/20
782/782 [==============================] - 183s 234ms/step - loss: 0.2911 - 782/782 [==============================] - 182s 233ms/step - loss: 0.1287 -
accuracy: 0.9066 accuracy: 0.9582
Epoch 20/20
Training for 20 more epoches 782/782 [==============================]
accuracy: 0.9554
- 182s 233ms/step - loss: 0.1372 -

https://github.com/SuyashShetty16/CIFAR-100-Image-Classification-using-ResNet/blob/main/CIFAR_100_Classification_NN_Project.ipynb 10/12 https://github.com/SuyashShetty16/CIFAR-100-Image-Classification-using-ResNet/blob/main/CIFAR_100_Classification_NN_Project.ipynb 11/12


24/04/2024, 13:39 CIFAR-100-Image-Classification-using-ResNet/CIFAR_100_Classification_NN_Project.ipynb at main · SuyashShetty16/CIF…
accu acy: 0. 55
Out[30]: <keras.src.callbacks.History at 0x7f29403f9cc0>

Visualizing learning curve of model


In [36]: # Logs from additional training for 20 epochs
history2 = {
'loss': [0.2709, 0.2576, 0.2506, 0.2301, 0.2141, 0.2093, 0.1979, 0.192
'accuracy': [0.9123, 0.9155, 0.9186, 0.9245, 0.9290, 0.9319, 0.9357, 0
}

# Concatenate the history data


combined_history = {
'loss': history.history['loss'] + history2['loss'],
'accuracy': history.history['accuracy'] + history2['accuracy']
}

# Plot loss vs epoch


plt.figure(figsize=(12, 4))
plt.subplot(1, 2, 1)

https://github.com/SuyashShetty16/CIFAR-100-Image-Classification-using-ResNet/blob/main/CIFAR_100_Classification_NN_Project.ipynb 12/12

You might also like