Created
July 13, 2021 06:46
-
-
Save Yuvnish017/e372cffe6567e4583f9676af5eb50679 to your computer and use it in GitHub Desktop.
OCR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def math_symbol_and_digits_recognition(input_shape=(32, 32, 1)): | |
regularizer = l2(0.01) | |
model = Sequential() | |
model.add(Input(shape=input_shape)) | |
model.add(Conv2D(32, (3, 3), strides=(1, 1), padding='same', | |
kernel_initializer=glorot_uniform(seed=0), | |
name='conv1', activity_regularizer=regularizer)) | |
model.add(Activation(activation='relu', name='act1')) | |
model.add(MaxPool2D((2, 2), strides=(2, 2))) | |
model.add(Conv2D(32, (3, 3), strides=(1, 1), padding='same', | |
kernel_initializer=glorot_uniform(seed=0), | |
name='conv2', activity_regularizer=regularizer)) | |
model.add(Activation(activation='relu', name='act2')) | |
model.add(MaxPool2D((2, 2), strides=(2, 2))) | |
model.add(Conv2D(64, (3, 3), strides=(1, 1), padding='same', | |
kernel_initializer=glorot_uniform(seed=0), | |
name='conv3', activity_regularizer=regularizer)) | |
model.add(Activation(activation='relu', name='act3')) | |
model.add(MaxPool2D((2, 2), strides=(2, 2))) | |
model.add(Flatten()) | |
model.add(Dropout(0.5)) | |
model.add(Dense(120, activation='relu', kernel_initializer=glorot_uniform(seed=0), name='fc1')) | |
model.add(Dense(84, activation='relu', kernel_initializer=glorot_uniform(seed=0), name='fc2')) | |
model.add(Dense(14, activation='softmax', kernel_initializer=glorot_uniform(seed=0), name='fc3')) | |
optimizer = Adam() | |
model.compile(loss='categorical_crossentropy', optimizer=optimizer, metrics=['accuracy']) | |
return model | |
model = math_symbol_and_digits_recognition(input_shape=(32, 32, 1)) | |
model.summary() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment