Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
prefix,
model_dict,
epoch,
batch_size,
log_per_step=100,
save_per_step=10000, ):
"""run_epoch"""
batch = 0
start = time.time()
batch_end = time.time()
for batch_feed_dict in py_reader():
if prefix == "train":
if batch_feed_dict["src_index"].shape[0] != batch_size:
log.warning(
'batch_feed_dict["src_index"].shape[0] != 1024, continue')
continue
batch_start = time.time()
batch += 1
batch_loss, batch_auc = exe.run(
program,
feed=batch_feed_dict,
fetch_list=[model_dict.loss.name, model_dict.auc.name])
batch_end = time.time()
if batch % log_per_step == 0:
log.info(
"Batch %s %s-Loss %s \t %s-Auc %s \t Speed(per batch) %.5lf sec"
% (batch, prefix, np.mean(batch_loss), prefix,
np.mean(batch_auc), batch_end - batch_start))
if batch != 0 and batch % save_per_step == 0: