Skip to content

Instantly share code, notes, and snippets.

@f-rumblefish
Created February 7, 2019 01:17
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save f-rumblefish/64787ad40f3f0f7feeca70db941eea99 to your computer and use it in GitHub Desktop.
Save f-rumblefish/64787ad40f3f0f7feeca70db941eea99 to your computer and use it in GitHub Desktop.
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D, Flatten, Dense
# parameters for architecture
input_shape = (224, 224, 3)
num_classes = 6
conv_size = 32
# parameters for training
batch_size = 32
num_epochs = 20
# build the model
model = Sequential()
model.add(Conv2D(conv_size, (3, 3), activation='relu', padding='same', input_shape=input_shape))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(conv_size, (3, 3), activation='relu', padding='same'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(conv_size, (3, 3), activation='relu', padding='same'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten())
model.add(Dense(512, activation='relu'))
model.add(Dense(512, activation='relu'))
model.add(Dense(num_classes, activation='softmax'))
# 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