Created
November 6, 2019 01:11
-
-
Save ageron/a38c67add35ba8dfcf19bc0fa12e47f0 to your computer and use it in GitHub Desktop.
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
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