Skip to content

Instantly share code, notes, and snippets.

@maxrohleder
Last active February 7, 2021 22:28
Show Gist options
  • Save maxrohleder/27e804d66eb0f54f0fcf4b06d957ea45 to your computer and use it in GitHub Desktop.
Save maxrohleder/27e804d66eb0f54f0fcf4b06d957ea45 to your computer and use it in GitHub Desktop.
Three different approaches to design a model in keras.
from tensorflow.keras import layers, models
# define the model
model = models.Sequential(name="Keras Test CNN")
model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.Flatten())
model.add(layers.Dense(64, activation='relu'))
model.add(layers.Dense(10))
# lets inspect our model so far
model.summary()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment