Skip to content

Instantly share code, notes, and snippets.

@KentaKudo
Created February 5, 2018 18:10
Show Gist options
  • Save KentaKudo/1e8e0f1647c47fe6d931c517885b5faf to your computer and use it in GitHub Desktop.
Save KentaKudo/1e8e0f1647c47fe6d931c517885b5faf to your computer and use it in GitHub Desktop.
def le_net(shape):
from keras.models import Model
from keras.layers import Dense, Conv2D, MaxPooling2D, Flatten, Input
inputs = Input(shape=shape)
x = Conv2D(6, (5, 5), padding='same', kernel_initializer='he_normal', activation='relu')(inputs)
x = MaxPooling2D(pool_size=(2, 2))(x)
x = Conv2D(16, (5, 5), padding='same', kernel_initializer='he_normal', activation='relu')(x)
x = MaxPooling2D(pool_size=(2, 2))(x)
x = Flatten()(x)
x = Dense(120, activation='relu', kernel_initializer='he_normal')(x)
x = Dense(84, activation='relu', kernel_initializer='he_normal')(x)
y = Dense(10, activation='softmax')(x)
model = Model(inputs=inputs, outputs=y)
model.compile(
loss='categorical_crossentropy',
optimizer='adam',
metrics=['accuracy']
)
return model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment