-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmodel_architecture.py
33 lines (24 loc) · 1.06 KB
/
model_architecture.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from tensorflow.keras.layers import Input, MaxPool1D, Conv1D, BatchNormalization, Dense, Dropout, Flatten
from tensorflow.keras import Model
def create_model(sample_rate):
inputs = Input((sample_rate, 1))
# 1D Convolutional Layers, first two blocks include max pooling
X = Conv1D(16, kernel_size=64, strides=2, activation="relu")(inputs)
X = BatchNormalization()(X)
X = MaxPool1D(pool_size=8, strides=8)(X)
X = Conv1D(32, kernel_size=32, strides=2, activation="relu")(X)
X = BatchNormalization()(X)
X = MaxPool1D(pool_size=8, strides=8)(X)
X = Conv1D(64, kernel_size=16, strides=2, activation="relu")(X)
X = BatchNormalization()(X)
X = Conv1D(128, kernel_size=8, strides=2, activation="relu")(X)
X = BatchNormalization()(X)
# Fully connected layers
X = Flatten()(X)
X = Dense(128, activation="relu")(X)
X = Dropout(rate=0.25)(X)
X = Dense(64, activation="relu")(X)
X = Dropout(rate=0.25)(X)
outputs = Dense(1, activation="sigmoid")(X)
model = Model(inputs=inputs, outputs=outputs)
return model