0
$\begingroup$

Context

I'm trying to create network for digits recognition. All digits are the same font and size of 40x40. I know that I can use feedforward network or CNN. I'd like to use the first one.

Issue

I cannot get decent results. I've tried depth/width manipulation as well as batch size and epochs changing. Results might seem okay with that ~96% of accuracy but it does not work well on unseen data. I'm passing this unseen data as (-1, 40, 40, 1) vector. Should I reshape it to (-1, 1600 ,1) before passing to prediction?

Can You give me some advice how to create this network properly?

My network

X = np.array(X).reshape(-1, IMG_WIDTH, IMG_HEIGHT, 1)
y = np.array(y)
X, test_X, y, test_y = train_test_split(X, y, test_size=0.25, random_state=42)
self.model = Sequential()
self.model.add(Flatten())
self.model.add(Dense(128, activation='relu', input_shape=X.shape[1:]))
self.model.add(Dropout(0.25))
self.model.add(Dense(no_classes, activation='softmax'))
self.model.compile(loss="categorical_crossentropy",
                   optimizer="adam",
                   metrics=['accuracy'])

self.history = self.model.fit(X, y, batch_size=3, epochs=30, validation_data=(test_X, test_y))

My results

enter image description here enter image description here

Example of training images

enter image description here enter image description here

New contributor
MASTER OF CODE is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$

Your Answer

MASTER OF CODE is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.