Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

keras - Validation acccuracy not improving

classifier = tf.keras.models.Sequential()
classifier.add(tf.keras.layers.Conv2D(32, (3, 3), input_shape = (224, 224, 3), activation = 'relu'))

classifier.add(tf.keras.layers.MaxPooling2D(pool_size = (2, 2)))

classifier.add(tf.keras.layers.Conv2D(32, (3, 3), activation = 'relu'))
classifier.add(tf.keras.layers.MaxPooling2D(pool_size = (2, 2)))

classifier.add(tf.keras.layers.Flatten())

classifier.add(tf.keras.layers.Dense(units = 128, activation = 'relu'))
classifier.add(tf.keras.layers.Dense(units = 1, activation = 'sigmoid'))

classifier.compile(optimizer = 'adam', loss = 'BinaryCrossentropy', metrics = ['accuracy'])

train_datagen = ImageDataGenerator(rescale = 1./255, shear_range = 0.2, zoom_range = 0.2, horizontal_flip = False)
test_datagen = ImageDataGenerator(rescale = 1./255)

training_set = train_datagen.flow_from_directory('/content/drive/MyDrive/Training/Training Data',
                                                 target_size = (224, 224),
                                                 batch_size = 50,
                                                 class_mode = 'sparse')

test_set = test_datagen.flow_from_directory('/content/drive/MyDrive/Training/Validation Data',
                                            target_size = (224, 224),
                                            batch_size = 50,
                                            class_mode = 'sparse')

classifier.fit(training_set,
                         steps_per_epoch = 4132/50, 
                         epochs = 10,
                         validation_data = test_set,
                         validation_steps = 978/50)

validation loss is changing but validation accuracy remain same. can anyone here tell me why this happens? I have dataset with two classes while training data of 4132 and validation data of 978.

question from:https://stackoverflow.com/questions/65861658/validation-acccuracy-not-improving

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...