MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / eval

Function eval

modelzoo/features/adamasync_optimizer/dien/train.py:92–124  ·  view source on GitHub ↗
(sess, test_data, model, model_path)

Source from the content-addressed store, hash-verified

90
91
92def eval(sess, test_data, model, model_path):
93
94 loss_sum = 0.
95 accuracy_sum = 0.
96 aux_loss_sum = 0.
97 nums = 0
98 stored_arr = []
99 for src, tgt in test_data:
100 nums += 1
101 uids, mids, cats, mid_his, cat_his, mid_mask, target, sl, noclk_mids, noclk_cats = prepare_data(
102 src, tgt, return_neg=True)
103 prob, loss, acc, aux_loss = model.calculate(sess, [
104 uids, mids, cats, mid_his, cat_his, mid_mask, target, sl,
105 noclk_mids, noclk_cats
106 ])
107 loss_sum += loss
108 aux_loss_sum = aux_loss
109 accuracy_sum += acc
110 prob_1 = prob[:, 0].tolist()
111 target_1 = target[:, 0].tolist()
112 for p, t in zip(prob_1, target_1):
113 stored_arr.append([p, t])
114 test_auc = calc_auc(stored_arr)
115 accuracy_sum = accuracy_sum / nums
116 loss_sum = loss_sum / nums
117 aux_loss_sum / nums
118 global best_auc
119 global best_case_acc
120 if best_auc < test_auc:
121 best_auc = test_auc
122 best_case_acc = accuracy_sum
123 model.save(sess, model_path)
124 return test_auc, loss_sum, accuracy_sum, aux_loss_sum
125
126
127def train(data_location='data',

Callers 2

trainFunction · 0.70
testFunction · 0.70

Calls 5

prepare_dataFunction · 0.70
calc_aucFunction · 0.50
calculateMethod · 0.45
appendMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected