Skip to content

Instantly share code, notes, and snippets.

@ageron
Created November 6, 2019 01:11
Show Gist options
  • Save ageron/a38c67add35ba8dfcf19bc0fa12e47f0 to your computer and use it in GitHub Desktop.
Save ageron/a38c67add35ba8dfcf19bc0fa12e47f0 to your computer and use it in GitHub Desktop.
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout, Flatten, Conv2D
from tensorflow.keras.layers import MaxPooling2D, BatchNormalization
keras.backend.clear_session()
np.random.seed(1000)
tf.random.set_seed(1000)
model = Sequential([
Conv2D(filters=96, kernel_size=(11,11), strides=(4,4), padding="same",
activation="relu", input_shape=(224,224,3)),
MaxPooling2D(pool_size=(3,3), strides=(2,2), padding="valid"),
Conv2D(filters=256, kernel_size=(5,5), strides=(1,1), padding="same",
activation="relu"),
MaxPooling2D(pool_size=(3,3), strides=(2,2), padding="valid"),
Conv2D(filters=384, kernel_size=(3,3), strides=(1,1), padding="same",
activation="relu"),
Conv2D(filters=384, kernel_size=(3,3), strides=(1,1), padding="same",
activation="relu"),
Conv2D(filters=256, kernel_size=(3,3), strides=(1,1), padding="same",
activation="relu"),
MaxPooling2D(pool_size=(3,3), strides=(2,2), padding="valid"),
Flatten(),
Dense(4096, activation="relu"),
Dropout(0.4),
Dense(4096, activation="relu"),
Dropout(0.4),
Dense(1000, activation="softmax")
])
model.summary()
model.compile(loss="categorical_crossentropy", optimizer="adam",
metrics=["accuracy"])
#model.fit(X_train, y_train, epochs=10,
# validation_data=(X_valid, y_valid))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment