Fix Tensorflow seed assignment

This commit is contained in:
coolneng 2021-06-07 19:26:21 +02:00
parent 0ce582250d
commit 08611de8e6
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
1 changed files with 2 additions and 5 deletions

View File

@ -17,7 +17,6 @@ def build_model() -> Model:
""" """
model = Sequential( model = Sequential(
[ [
# Two convolutions + maxpooling blocks
layers.Conv1D( layers.Conv1D(
filters=16, filters=16,
kernel_size=5, kernel_size=5,
@ -32,9 +31,7 @@ def build_model() -> Model:
kernel_regularizer=l2(L2), kernel_regularizer=l2(L2),
), ),
layers.MaxPool1D(pool_size=3, strides=1), layers.MaxPool1D(pool_size=3, strides=1),
# Flatten the input volume
layers.Flatten(), layers.Flatten(),
# Two fully connected layers, each followed by a dropout layer
layers.Dense( layers.Dense(
units=16, units=16,
activation="relu", activation="relu",
@ -47,7 +44,7 @@ def build_model() -> Model:
kernel_regularizer=l2(L2), kernel_regularizer=l2(L2),
), ),
layers.Dropout(rate=0.3), layers.Dropout(rate=0.3),
# Output layer with softmax activation # FIXME Change output size
layers.Dense(units=len(BASES), activation="softmax"), layers.Dense(units=len(BASES), activation="softmax"),
] ]
) )
@ -74,7 +71,7 @@ def run(data_file, label_file, seed_value=42) -> None:
Create a dataset, a model and runs training and evaluation on it Create a dataset, a model and runs training and evaluation on it
""" """
seed(seed_value) seed(seed_value)
set_seed(seed) set_seed(seed_value)
train_data, eval_data, test_data = dataset_creation(data_file, label_file) train_data, eval_data, test_data = dataset_creation(data_file, label_file)
tensorboard = TensorBoard(log_dir=LOG_DIR, histogram_freq=1, profile_batch=0) tensorboard = TensorBoard(log_dir=LOG_DIR, histogram_freq=1, profile_batch=0)
model = build_model() model = build_model()