Skip to content

Instantly share code, notes, and snippets.

@f-rumblefish
Last active October 7, 2019 01:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save f-rumblefish/287a4b90dbf734295651d54e5e8673dd to your computer and use it in GitHub Desktop.
Save f-rumblefish/287a4b90dbf734295651d54e5e8673dd to your computer and use it in GitHub Desktop.
from keras.applications.inception_v3 import InceptionV3
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 InceptionV3 from Keras
InceptionV3_model = InceptionV3(include_top=False, input_shape=input_shape)
# add custom Layers
x = InceptionV3_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 = InceptionV3_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)
@yunhyejoung
Copy link

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