Я тренирую модель впервые, но получаю низкую точность. Любая помощь?
from keras.models import Sequential
from keras.layers import Conv2D
from keras.layers import MaxPooling2D
from keras.layers import Flatten
from keras.layers import Dense
#Initialising the CNN
classifier = Sequential()
#Step 1 - Convolution
classifier.add(Conv2D(32, (3, 3), input_shape = (64, 64, 3), activation = 'relu'))
#Step 2 - pooling
classifier.add(MaxPooling2D(pool_size= (2, 2)))
#ADD Another Layer
classifier.add(Conv2D(32, (3, 3), activation = 'relu'))
classifier.add(MaxPooling2D(pool_size= (2, 2)))
classifier.add(Conv2D(64, (3, 3), activation = 'relu'))
classifier.add(MaxPooling2D(pool_size= (2, 2)))
classifier.add(Conv2D(64, (3, 3), activation = 'relu'))
classifier.add(MaxPooling2D(pool_size= (2, 2)))
#Step 3- Flattening
classifier.add(Flatten())
#Step 4 - Full connection
classifier.add(Dense(activation="relu", units=128))
classifier.add(Dense(activation="softmax", units=24))
#Compiling the CNN
classifier.compile(optimizer = 'adam', loss = 'categorical_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)
train_generator = train_datagen.flow_from_directory(
'data/train',
target_size=(64, 64),
batch_size=32,
class_mode='categorical')
validation_generator = test_datagen.flow_from_directory(
'data/test',
target_size=(64, 64),
batch_size=32,
class_mode='categorical')
classifier.fit_generator(
train_generator,
steps_per_epoch=4800,
epochs=5,
validation_data=validation_generator,
validation_steps=800)