Skip to content

Instantly share code, notes, and snippets.

@f-rumblefish
Last active November 20, 2019 01:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save f-rumblefish/f75e00b59261f27ba540cbacfa9cb02d to your computer and use it in GitHub Desktop.
Save f-rumblefish/f75e00b59261f27ba540cbacfa9cb02d to your computer and use it in GitHub Desktop.
from keras.applications.mobilenet import MobileNet
from keras.models import Model
from keras.layers import Dense, GlobalAveragePooling2D
# parameters for architecture
input_shape = (224, 224, 3)
num_classes = 6
conv_size = 32
# parameters for training
batch_size = 32
num_epochs = 20
# load MobileNet from Keras
MobileNet_model = MobileNet(include_top=False, input_shape=input_shape)
# add custom Layers
x = MobileNet_model.output
x = GlobalAveragePooling2D()(x)
x = Dense(512, activation="relu")(x)
Custom_Output = Dense(num_classes, activation='softmax')(x)
# define the input and output of the model
model = Model(inputs = MobileNet_model.input, outputs = Custom_Output)
# compile the model
model.compile(loss='categorical_crossentropy',
optimizer='adam',
metrics=['accuracy'])
model.summary()
# train the model
history = model.fit(x_train, y_train,
batch_size=batch_size,
epochs=num_epochs,
verbose=1,
validation_split=0.1)
@mehio
Copy link

mehio commented Jul 20, 2019

which version of mobilenet is this? V1 or V2?
And is there a way to make it realtime like YOLO?

@yunhyejoung
Copy link

which version of mobilenet is this? V1 or V2?
And is there a way to make it realtime like YOLO?


x_train was not declared.
So there is an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment