Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created December 5, 2020 06:39
Show Gist options
  • Save amankharwal/0d96aaef6420a82d51975e43d2282a37 to your computer and use it in GitHub Desktop.
Save amankharwal/0d96aaef6420a82d51975e43d2282a37 to your computer and use it in GitHub Desktop.
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(32, (3,3), activation='relu', input_shape=(28, 28, 1)),
tf.keras.layers.MaxPooling2D(2,2),
tf.keras.layers.Conv2D(32, (3,3), activation='relu'),
tf.keras.layers.MaxPooling2D(2,2),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(512, activation='relu'),
tf.keras.layers.Dense(26, activation='softmax')
])
# Compile Model.
model.compile(
optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy']
)
# Train the Model
history = model.fit_generator(train_datagen.flow(training_images, training_labels, batch_size=32),
steps_per_epoch=len(training_images) / 32,
epochs=10,
validation_data=validation_datagen.flow(testing_images, testing_labels, batch_size=32),
validation_steps=len(testing_images) / 32)
model.evaluate(testing_images, testing_labels, verbose=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment