Skip to content

Commit

Permalink
more dense layer
Browse files Browse the repository at this point in the history
  • Loading branch information
orbxball committed Apr 16, 2017
1 parent a6818f9 commit 8002585
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hw3/test_cnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def ensure_dir(file_path):
height = width = 48
num_classes = 7
input_shape = (height, width, 1)
model_name = 'pre3.h5'
model_name = 'pre4.h5'

# Read the test data
with open(sys.argv[1], "r+") as f:
Expand Down
12 changes: 8 additions & 4 deletions hw3/train_cnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
num_classes = 7
input_shape = (height, width, 1)
batch_size = 128
epochs = 50
epochs = 30
zoom_range = 0.05
model_name = 'pre3.h5'
model_name = 'pre4.h5'
isValid = 1

# Read the train data
Expand Down Expand Up @@ -61,18 +61,22 @@
model.add(Conv2D(128, (3, 3), padding='same'))
model.add(LeakyReLU(alpha=0.03))
model.add(BatchNormalization())
model.add(AveragePooling2D(pool_size=(2, 2), padding='same'))
model.add(MaxPooling2D(pool_size=(2, 2), padding='same'))
model.add(Dropout(0.3))

model.add(Conv2D(256, (3, 3), padding='same'))
model.add(LeakyReLU(alpha=0.03))
model.add(BatchNormalization())
model.add(AveragePooling2D(pool_size=(2, 2), padding='same'))
model.add(MaxPooling2D(pool_size=(2, 2), padding='same'))
model.add(Dropout(0.3))

model.add(Flatten())

model.add(Dense(512, activation='relu'))
model.add(BatchNormalization())
model.add(Dropout(0.5))
model.add(Dense(128, activation='relu'))
model.add(BatchNormalization())
model.add(Dropout(0.5))
model.add(Dense(num_classes))
model.add(Activation('softmax'))
Expand Down

0 comments on commit 8002585

Please sign in to comment.