Build model incrementally
This commit is contained in:
parent
19ed847d12
commit
d2e5fd0fa3
69
src/model.py
69
src/model.py
|
@ -15,39 +15,44 @@ def build_model() -> Model:
|
|||
"""
|
||||
Build the CNN model
|
||||
"""
|
||||
model = Sequential(
|
||||
[
|
||||
layers.Conv1D(
|
||||
filters=16,
|
||||
kernel_size=5,
|
||||
activation="relu",
|
||||
kernel_regularizer=l2(L2),
|
||||
),
|
||||
layers.MaxPool1D(pool_size=3, strides=1),
|
||||
layers.Conv1D(
|
||||
filters=16,
|
||||
kernel_size=3,
|
||||
activation="relu",
|
||||
kernel_regularizer=l2(L2),
|
||||
),
|
||||
layers.MaxPool1D(pool_size=3, strides=1),
|
||||
layers.Flatten(),
|
||||
layers.Dense(
|
||||
units=16,
|
||||
activation="relu",
|
||||
kernel_regularizer=l2(L2),
|
||||
),
|
||||
layers.Dropout(rate=0.3),
|
||||
layers.Dense(
|
||||
units=16,
|
||||
activation="relu",
|
||||
kernel_regularizer=l2(L2),
|
||||
),
|
||||
layers.Dropout(rate=0.3),
|
||||
# FIXME Change output size
|
||||
layers.Dense(units=len(BASES), activation="softmax"),
|
||||
]
|
||||
model = Sequential()
|
||||
model.add(
|
||||
layers.Conv1D(
|
||||
filters=16,
|
||||
kernel_size=5,
|
||||
activation="relu",
|
||||
kernel_regularizer=l2(L2),
|
||||
)
|
||||
)
|
||||
model.add(layers.MaxPool1D(pool_size=3, strides=1))
|
||||
model.add(
|
||||
layers.Conv1D(
|
||||
filters=16,
|
||||
kernel_size=3,
|
||||
activation="relu",
|
||||
kernel_regularizer=l2(L2),
|
||||
)
|
||||
)
|
||||
model.add(layers.MaxPool1D(pool_size=3, strides=1))
|
||||
model.add(layers.Flatten())
|
||||
model.add(
|
||||
layers.Dense(
|
||||
units=16,
|
||||
activation="relu",
|
||||
kernel_regularizer=l2(L2),
|
||||
)
|
||||
)
|
||||
model.add(layers.Dropout(rate=0.3))
|
||||
model.add(
|
||||
layers.Dense(
|
||||
units=16,
|
||||
activation="relu",
|
||||
kernel_regularizer=l2(L2),
|
||||
)
|
||||
)
|
||||
model.add(layers.Dropout(rate=0.3))
|
||||
# FIXME Change output size
|
||||
model.add(layers.Dense(units=len(BASES), activation="softmax"))
|
||||
model.compile(
|
||||
optimizer=Adam(LEARNING_RATE),
|
||||
loss=sparse_categorical_crossentropy,
|
||||
|
|
Loading…
Reference in New Issue