Вот CNN, реализованный в наборе данных cifar10, который выдаст искомый результат @Ishak Barkat
( Реализовано в Tensorflow '2.0.0-alpha0' )
from tensorflow import keras
import tensorflow as tf
import numpy as np
cifar10= tf.keras.datasets.cifar10
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
x_train = np.reshape(x_train, (x_train.shape[0], 32,32, 3))
x_test = np.reshape(x_test, (x_test.shape[0], 32,32, 3))
model = tf.keras.models.Sequential([
tf.keras.layers.Reshape((32,32,3), input_shape=(32,32,3)),
tf.keras.layers.Conv2D(80, 5, activation=tf.nn.relu),
tf.keras.layers.MaxPool2D(2),
tf.keras.layers.BatchNormalization(2),
tf.keras.layers.Conv2D(64, 5, activation=tf.nn.relu),
tf.keras.layers.MaxPool2D(2),
tf.keras.layers.BatchNormalization(2),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(1024, activation=tf.nn.relu),
tf.keras.layers.Dropout(0.8),
tf.keras.layers.Dense(29, activation=tf.nn.softmax)
])
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.fit(x_train, y_train, epochs=1)
model.evaluate(x_test, y_test)
model.summary()
А вот и вывод
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
reshape (Reshape) (None, 32, 32, 3) 0
_________________________________________________________________
conv2d (Conv2D) (None, 28, 28, 80) 6080
_________________________________________________________________
max_pooling2d (MaxPooling2D) (None, 14, 14, 80) 0
_________________________________________________________________
batch_normalization_v2 (Batc (None, 14, 14, 80) 56
_________________________________________________________________
conv2d_1 (Conv2D) (None, 10, 10, 64) 128064
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 5, 5, 64) 0
_________________________________________________________________
batch_normalization_v2_1 (Ba (None, 5, 5, 64) 20
_________________________________________________________________
flatten (Flatten) (None, 1600) 0
_________________________________________________________________
dense (Dense) (None, 1024) 1639424
_________________________________________________________________
dropout (Dropout) (None, 1024) 0
_________________________________________________________________
dense_1 (Dense) (None, 29) 29725
=================================================================
Надеюсь, это поможет