Cifar 10 help using CNN

from keras import datasets

(trainimg,trainlb),(testimg,testlb) = datasets.cifar10.load_data()

import numpy
import matplotlib.pyplot as plt
from keras import models
from keras.utils import to_categorical
from keras import layers

print(trainimg.shape)
print(trainlb.shape)
print(testimg.shape)
print(testlb.shape)

trainimg = trainimg/255
trainlb = to_categorical(trainlb)

model = models.Sequential()
model.add(layers.Conv2D(filters=10,kernel_size = (5,5), input_shape=(32,32,3),activation='relu'))
model.add(layers.Dropout(0.3))
model.add(layers.Conv2D(filters=20,kernel_size = (5,5), activation='relu'))
model.add(layers.Conv2D(filters=30,kernel_size = (3,3), activation='relu'))
model.add(layers.MaxPooling2D(pool_size=(2,2)))
model.add(layers.Conv2D(filters=40,kernel_size = (3,3), activation='relu'))
model.add(layers.Dropout(0.3))
model.add(layers.MaxPooling2D(pool_size=(2,2)))
model.add(layers.Flatten())
model.add(layers.Dense(500,activation='relu'))
model.add(layers.Dropout(0.5))
model.add(layers.Dense(300,activation='relu'))
model.add(layers.Dropout(0.5))
model.add(layers.Dense(100,activation='relu'))
model.add(layers.Dropout(0.5))
model.add(layers.Dense(10,activation='softmax'))
model.compile(loss='categorical_crossentropy', metrics=['accuracy'], optimizer='adam')
model.fit(trainimg,trainlb,epochs=200,batch_size=1000,validation_split=0.6)



so thats my code. and im getting 98% accuracy for training. but getting 65% approximately for testing. Why is that? how can i increase Testing accuracy?
im new to coding.

Have you looked at the forum?  I see at least two posts claiming 90%+ accuracy.

1 Like