Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Code repetition #206

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions river_dl/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def train_model(
np.random.seed(seed)
random.seed(seed)


# If keep portion is specified, mask the sequence outside that portion to
# force the loss function focus on only the keep portion.
if keep_portion is not None:
Expand Down Expand Up @@ -98,25 +97,12 @@ def train_model(

# train the model
start_time = datetime.datetime.now()
args = x_trn, y_trn, epochs, batch_size, callbacks, validation_data # x=x_trn, y=y_trn
if use_cpu:
with tf.device('/CPU:0'):
model.fit(
x=x_trn,
y=y_trn,
epochs=epochs,
batch_size=batch_size,
callbacks=callbacks,
validation_data=validation_data
)
model.fit(*args)
else:
model.fit(
x=x_trn,
y=y_trn,
epochs=epochs,
batch_size=batch_size,
callbacks=callbacks,
validation_data=validation_data
)
model.fit(*args)

# write out time
end_time = datetime.datetime.now()
Expand Down