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.
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?
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))
Example of training images