提交 df049189 编写于 作者: Z zhanke

add epoch time print

上级 49f80761
......@@ -50,7 +50,7 @@ def novelty_at_k(topk_items, item_degree_dict, num_user, k):
"""Calculate the novelty at k"""
avg_nov = []
for item in topk_items[:k]:
avg_nov.append(-np.log2(item_degree_dict[item] / num_user))
avg_nov.append(-np.log2((item_degree_dict[item] + 1e-8) / num_user))
return np.mean(avg_nov)
......
......@@ -16,6 +16,7 @@
BGCF training script.
"""
import os
import time
import datetime
from mindspore import Tensor
......@@ -56,6 +57,7 @@ def train_and_eval():
for _epoch in range(1, parser.num_epoch + 1):
epoch_start = time.time()
iter_num = 1
for data in itr:
......@@ -96,7 +98,7 @@ def train_and_eval():
if iter_num == num_iter:
print('Epoch', '%03d' % _epoch, 'iter', '%02d' % iter_num,
'loss',
'{}'.format(train_loss))
'{}, cost:{:.4f}'.format(train_loss, time.time() - epoch_start))
iter_num += 1
if _epoch % parser.eval_interval == 0:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册