Validation Accuracy shown during epochs much higher than what I actually get
up vote
0
down vote
favorite
I am new to Keras and CNN and therefore struggling with the following.
When I train using image dataset using the follwing code:
train_batches = gen1.flow_from_directory(train_path, target_size=(224,224),classes = ['garbage', 'recycled', 'organic'], batch_size = batch)
valid_batches = gen1.flow_from_directory(valid_path, target_size=(224,224), classes = ['garbage', 'recycled', 'organic'], batch_size = batch)
test_batches = gen1.flow_from_directory(test_path, target_size=(224,224), classes = ['garbage', 'recycled', 'organic'], batch_size = batch)
model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=( 224, 224, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten()) # this converts our 3D feature maps to 1D feature vectors
model.add(Dense(64))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(3))
model.add(Activation('softmax'))
model.compile(optimizer=Adam(lr=.0001), loss= 'categorical_crossentropy', metrics = ['accuracy'])
history = model.fit_generator(train_batches, steps_per_epoch =training_data_size//batch, validation_data = valid_batches, validation_steps=validation_data_size//batch, epochs=5, verbose=2)
model.save_weights('Try1.h5')
I get the 77% validation accuracy after 5 epochs as can be seen in the pic :
enter image description here
But when I try to create a confusion matrix for it using I get 35% validation accuracy:
predictions = model.predict_generator(valid_batches, steps=validation_data_size//batch,verbose=1)
conf_mat2 = confusion_matrix(valid_batches.classes, np.argmax(predictions,axis=1))
keras conv-neural-network
add a comment |
up vote
0
down vote
favorite
I am new to Keras and CNN and therefore struggling with the following.
When I train using image dataset using the follwing code:
train_batches = gen1.flow_from_directory(train_path, target_size=(224,224),classes = ['garbage', 'recycled', 'organic'], batch_size = batch)
valid_batches = gen1.flow_from_directory(valid_path, target_size=(224,224), classes = ['garbage', 'recycled', 'organic'], batch_size = batch)
test_batches = gen1.flow_from_directory(test_path, target_size=(224,224), classes = ['garbage', 'recycled', 'organic'], batch_size = batch)
model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=( 224, 224, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten()) # this converts our 3D feature maps to 1D feature vectors
model.add(Dense(64))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(3))
model.add(Activation('softmax'))
model.compile(optimizer=Adam(lr=.0001), loss= 'categorical_crossentropy', metrics = ['accuracy'])
history = model.fit_generator(train_batches, steps_per_epoch =training_data_size//batch, validation_data = valid_batches, validation_steps=validation_data_size//batch, epochs=5, verbose=2)
model.save_weights('Try1.h5')
I get the 77% validation accuracy after 5 epochs as can be seen in the pic :
enter image description here
But when I try to create a confusion matrix for it using I get 35% validation accuracy:
predictions = model.predict_generator(valid_batches, steps=validation_data_size//batch,verbose=1)
conf_mat2 = confusion_matrix(valid_batches.classes, np.argmax(predictions,axis=1))
keras conv-neural-network
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am new to Keras and CNN and therefore struggling with the following.
When I train using image dataset using the follwing code:
train_batches = gen1.flow_from_directory(train_path, target_size=(224,224),classes = ['garbage', 'recycled', 'organic'], batch_size = batch)
valid_batches = gen1.flow_from_directory(valid_path, target_size=(224,224), classes = ['garbage', 'recycled', 'organic'], batch_size = batch)
test_batches = gen1.flow_from_directory(test_path, target_size=(224,224), classes = ['garbage', 'recycled', 'organic'], batch_size = batch)
model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=( 224, 224, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten()) # this converts our 3D feature maps to 1D feature vectors
model.add(Dense(64))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(3))
model.add(Activation('softmax'))
model.compile(optimizer=Adam(lr=.0001), loss= 'categorical_crossentropy', metrics = ['accuracy'])
history = model.fit_generator(train_batches, steps_per_epoch =training_data_size//batch, validation_data = valid_batches, validation_steps=validation_data_size//batch, epochs=5, verbose=2)
model.save_weights('Try1.h5')
I get the 77% validation accuracy after 5 epochs as can be seen in the pic :
enter image description here
But when I try to create a confusion matrix for it using I get 35% validation accuracy:
predictions = model.predict_generator(valid_batches, steps=validation_data_size//batch,verbose=1)
conf_mat2 = confusion_matrix(valid_batches.classes, np.argmax(predictions,axis=1))
keras conv-neural-network
I am new to Keras and CNN and therefore struggling with the following.
When I train using image dataset using the follwing code:
train_batches = gen1.flow_from_directory(train_path, target_size=(224,224),classes = ['garbage', 'recycled', 'organic'], batch_size = batch)
valid_batches = gen1.flow_from_directory(valid_path, target_size=(224,224), classes = ['garbage', 'recycled', 'organic'], batch_size = batch)
test_batches = gen1.flow_from_directory(test_path, target_size=(224,224), classes = ['garbage', 'recycled', 'organic'], batch_size = batch)
model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=( 224, 224, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten()) # this converts our 3D feature maps to 1D feature vectors
model.add(Dense(64))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(3))
model.add(Activation('softmax'))
model.compile(optimizer=Adam(lr=.0001), loss= 'categorical_crossentropy', metrics = ['accuracy'])
history = model.fit_generator(train_batches, steps_per_epoch =training_data_size//batch, validation_data = valid_batches, validation_steps=validation_data_size//batch, epochs=5, verbose=2)
model.save_weights('Try1.h5')
I get the 77% validation accuracy after 5 epochs as can be seen in the pic :
enter image description here
But when I try to create a confusion matrix for it using I get 35% validation accuracy:
predictions = model.predict_generator(valid_batches, steps=validation_data_size//batch,verbose=1)
conf_mat2 = confusion_matrix(valid_batches.classes, np.argmax(predictions,axis=1))
keras conv-neural-network
keras conv-neural-network
asked Nov 11 at 15:47
vaibhav gupta
11
11
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53250410%2fvalidation-accuracy-shown-during-epochs-much-higher-than-what-i-actually-get%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown