Build model incrementally

This commit is contained in:
coolneng 2021-06-14 23:32:49 +02:00
parent 19ed847d12
commit d2e5fd0fa3
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
1 changed files with 37 additions and 32 deletions

View File

@ -15,39 +15,44 @@ def build_model() -> Model:
""" """
Build the CNN model Build the CNN model
""" """
model = Sequential( model = Sequential()
[ model.add(
layers.Conv1D( layers.Conv1D(
filters=16, filters=16,
kernel_size=5, kernel_size=5,
activation="relu", activation="relu",
kernel_regularizer=l2(L2), kernel_regularizer=l2(L2),
), )
layers.MaxPool1D(pool_size=3, strides=1), )
model.add(layers.MaxPool1D(pool_size=3, strides=1))
model.add(
layers.Conv1D( layers.Conv1D(
filters=16, filters=16,
kernel_size=3, kernel_size=3,
activation="relu", activation="relu",
kernel_regularizer=l2(L2), 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.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( model.compile(
optimizer=Adam(LEARNING_RATE), optimizer=Adam(LEARNING_RATE),
loss=sparse_categorical_crossentropy, loss=sparse_categorical_crossentropy,