├── README.md ├── all_rank.PNG ├── data ├── Beauty.txt ├── Beauty_item2attributes.json ├── Beauty_sample.txt ├── LastFM.txt ├── LastFM_item2attributes.json ├── LastFM_sample.txt ├── Sports_and_Outdoors.txt ├── Sports_and_Outdoors_item2attributes.json ├── Sports_and_Outdoors_sample.txt ├── Toys_and_Games.txt ├── Toys_and_Games_item2attributes.json ├── Toys_and_Games_sample.txt ├── Yelp.txt ├── Yelp_item2attributes.json ├── Yelp_sample.txt ├── data_process.py └── generate_test.py ├── datasets.py ├── model.PNG ├── models.py ├── modules.py ├── reproduce ├── Beauty-epochs-150.pt ├── Finetune_sample-Beauty-0.txt ├── Finetune_sample-Beauty-150.txt ├── Finetune_sample-LastFM-0.txt ├── Finetune_sample-LastFM-150.txt ├── Finetune_sample-Sports_and_Outdoors-0.txt ├── Finetune_sample-Sports_and_Outdoors-100.txt ├── Finetune_sample-Toys_and_Games-0.txt ├── Finetune_sample-Toys_and_Games-150.txt ├── Finetune_sample-Yelp-0.txt ├── Finetune_sample-Yelp-100.txt ├── LastFM-epochs-150.pt ├── README.md ├── Sports_and_Outdoors-epochs-100.pt ├── Toys_and_Games-epochs-150.pt └── Yelp-epochs-100.pt ├── requirements.txt ├── run_finetune_full.py ├── run_finetune_sample.py ├── run_pretrain.py ├── sample_99.PNG ├── trainers.py └── utils.py /README.md: -------------------------------------------------------------------------------- 1 | 2 | Code for our CIKM 2020 Paper ["**S3-Rec: Self-Supervised Learning for Sequential 3 | Recommendation with Mutual Information Maximization"**](https://arxiv.org/abs/2008.07873) 4 | 5 | ## Overview 6 | The major contributions of our paper are four self-supervised optimization objectives, which capture item-attribute, sequence-item, sequence-attribute and sequence-subsequence correlations in raw data, respectively. And these optimization objectives are developed in a unified form of mutual information maximization. 7 | 8 | ![avatar](model.PNG) 9 | 10 | ## Reproduce 11 | Since we conduct extensive experiments on ***six datasets*** and under ***two evaluation scene*** (ranking with 99 negative items or all items), you can check the ***./reproduce/ directory*** to try your targeted dataset or evaluation scene as you like. 12 | 13 | ## Results 14 | We illustrate the performance of our method comparing with different methods on six datasets. The best performance and the second best performance methods are denoted in bold and underlined fonts respectively. 15 | 16 | Considering some recent researchers argue the effectiveness of different ranking strategies for testing recommender systems, we conduct experiments with two mainstream evaluation approaches. 17 | [**It is really time-consuming for the additional experiment, please do not save your star :)**](https://github.com/RUCAIBox/CIKM2020-S3Rec/) 18 | 19 | In the PAPER, we pair the ground-truth item with **99 randomly sampled negative items** that the user has not interacted with, and report the results of HR@{1, 5, 10}, NDCG@{5, 10} and MRR. The used test files are named as 20 | ``` 21 | data-name_sample.txt 22 | ``` 23 | The results are shown in the following picture. 24 | ![avatar](sample_99.PNG) 25 | 26 | 27 | We also rank the ground-truth item with **all items**. We omit the FM and AutoInt because they need enumerate all user-item pairs, which take a very long time. 28 | The results are shown in the following picture. 29 | 30 | 31 | ![avatar](all_rank.PNG) 32 | 33 | ### requirements 34 | ```shell script 35 | pip install -r requirements.txt 36 | ``` 37 | 38 | ## data format 39 | ```shell script 40 | data preprocess 41 | ./data/data_process.py 42 | 43 | generate negative items for testing 44 | ./data/generate_test.py 45 | 46 | 47 | data-name.txt 48 | one user per line 49 | user_1 item_1 item_2 ... 50 | user_2 item_1 item_2 ... 51 | 52 | data-name_sample.txt 53 | one user per line 54 | user_1 neg_item_1 neg_item_2 ... 55 | user_2 neg_item_1 neg_item_2 ... 56 | 57 | data-name_item2attributes.json 58 | {item_1:[attr, ...], item_2:[attr, ...], ... } 59 | ``` 60 | 61 | ## pretrain 62 | ```shell script 63 | python run_pretrain.py \ 64 | --data_name data_name 65 | ``` 66 | 67 | ## finetune 68 | We support two evaluation methods. For more details, please check the ./reproduce directory. 69 | 70 | + Rank ground-truth item with 99 randomly sampled negative items 71 | ```shell script 72 | python run_finetune_sample.py \ 73 | --data_name data_name \ 74 | --ckp pretrain_epochs_num 75 | ``` 76 | 77 | + Rank the ground-truth item with all the items 78 | ```shell script 79 | python run_finetune_full.py \ 80 | --data_name data_name \ 81 | --ckp pretrain_epochs_num 82 | ``` 83 | 84 | 85 | ### Cite 86 | If you find our codes and datasets useful for your research or development, please cite our paper: 87 | 88 | ``` 89 | @inproceedings{CIKM2020-S3Rec, 90 | author = {Kun Zhou and 91 | Hui Wang and 92 | Wayne Xin Zhao and 93 | Yutao Zhu and 94 | Sirui Wang and 95 | Fuzheng Zhang and 96 | Zhongyuan Wang and 97 | Ji{-}Rong Wen}, 98 | title = {S3-Rec: Self-Supervised Learning for Sequential Recommendation with 99 | Mutual Information Maximization}, 100 | booktitle = {{CIKM} '20: The 29th {ACM} International Conference on Information 101 | and Knowledge Management, Virtual Event, Ireland, October 19-23, 2020}, 102 | pages = {1893--1902}, 103 | publisher = {{ACM}}, 104 | year = {2020} 105 | } 106 | ``` 107 | 108 | ### Contact 109 | If you have any questions for our paper or codes, please send an email to hui.wang@ruc.edu.cn. 110 | -------------------------------------------------------------------------------- /all_rank.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RUCAIBox/CIKM2020-S3Rec/2a81540ae18615d88ef88227b0c066e5b74781e5/all_rank.PNG -------------------------------------------------------------------------------- /data/data_process.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @Time : 2020/4/4 8:18 3 | # @Author : Hui Wang 4 | 5 | from collections import defaultdict 6 | import random 7 | import numpy as np 8 | import pandas as pd 9 | import json 10 | import pickle 11 | import gzip 12 | import tqdm 13 | 14 | 15 | def parse(path): # for Amazon 16 | g = gzip.open(path, 'r') 17 | for l in g: 18 | yield eval(l) 19 | 20 | # return (user item timestamp) sort in get_interaction 21 | def Amazon(dataset_name, rating_score): 22 | ''' 23 | reviewerID - ID of the reviewer, e.g. A2SUAM1J3GNN3B 24 | asin - ID of the product, e.g. 0000013714 25 | reviewerName - name of the reviewer 26 | helpful - helpfulness rating of the review, e.g. 2/3 27 | --"helpful": [2, 3], 28 | reviewText - text of the review 29 | --"reviewText": "I bought this for my husband who plays the piano. ..." 30 | overall - rating of the product 31 | --"overall": 5.0, 32 | summary - summary of the review 33 | --"summary": "Heavenly Highway Hymns", 34 | unixReviewTime - time of the review (unix time) 35 | --"unixReviewTime": 1252800000, 36 | reviewTime - time of the review (raw) 37 | --"reviewTime": "09 13, 2009" 38 | ''' 39 | datas = [] 40 | # older Amazon 41 | data_flie = '/path/reviews_' + dataset_name + '.json.gz' 42 | # latest Amazon 43 | # data_flie = '/home/hui_wang/data/new_Amazon/' + dataset_name + '.json.gz' 44 | for inter in parse(data_flie): 45 | if float(inter['overall']) <= rating_score: # 小于一定分数去掉 46 | continue 47 | user = inter['reviewerID'] 48 | item = inter['asin'] 49 | time = inter['unixReviewTime'] 50 | datas.append((user, item, int(time))) 51 | return datas 52 | 53 | 54 | def Amazon_meta(dataset_name, data_maps): 55 | ''' 56 | asin - ID of the product, e.g. 0000031852 57 | --"asin": "0000031852", 58 | title - name of the product 59 | --"title": "Girls Ballet Tutu Zebra Hot Pink", 60 | description 61 | price - price in US dollars (at time of crawl) 62 | --"price": 3.17, 63 | imUrl - url of the product image (str) 64 | --"imUrl": "http://ecx.images-amazon.com/images/I/51fAmVkTbyL._SY300_.jpg", 65 | related - related products (also bought, also viewed, bought together, buy after viewing) 66 | --"related":{ 67 | "also_bought": ["B00JHONN1S"], 68 | "also_viewed": ["B002BZX8Z6"], 69 | "bought_together": ["B002BZX8Z6"] 70 | }, 71 | salesRank - sales rank information 72 | --"salesRank": {"Toys & Games": 211836} 73 | brand - brand name 74 | --"brand": "Coxlures", 75 | categories - list of categories the product belongs to 76 | --"categories": [["Sports & Outdoors", "Other Sports", "Dance"]] 77 | ''' 78 | datas = {} 79 | meta_flie = '/path/meta_' + dataset_name + '.json.gz' 80 | item_asins = list(data_maps['item2id'].keys()) 81 | for info in parse(meta_flie): 82 | if info['asin'] not in item_asins: 83 | continue 84 | datas[info['asin']] = info 85 | return datas 86 | 87 | def Yelp(date_min, date_max, rating_score): 88 | datas = [] 89 | data_flie = '/path/yelp_academic_dataset_review.json' 90 | lines = open(data_flie).readlines() 91 | for line in tqdm.tqdm(lines): 92 | review = json.loads(line.strip()) 93 | user = review['user_id'] 94 | item = review['business_id'] 95 | rating = review['stars'] 96 | # 2004-10-12 10:13:32 2019-12-13 15:51:19 97 | date = review['date'] 98 | # 剔除一些例子 99 | if date < date_min or date > date_max or float(rating) <= rating_score: 100 | continue 101 | time = date.replace('-','').replace(':','').replace(' ','') 102 | datas.append((user, item, int(time))) 103 | return datas 104 | 105 | 106 | def Yelp_meta(datamaps): 107 | meta_infos = {} 108 | meta_file = '/home/hui_wang/data/Yelp/yelp_academic_dataset_business.json' 109 | item_ids = list(datamaps['item2id'].keys()) 110 | lines = open(meta_file).readlines() 111 | for line in tqdm.tqdm(lines): 112 | info = json.loads(line) 113 | if info['business_id'] not in item_ids: 114 | continue 115 | meta_infos[info['business_id']] = info 116 | return meta_infos 117 | 118 | 119 | def add_comma(num): 120 | # 1000000 -> 1,000,000 121 | str_num = str(num) 122 | res_num = '' 123 | for i in range(len(str_num)): 124 | res_num += str_num[i] 125 | if (len(str_num)-i-1) % 3 == 0: 126 | res_num += ',' 127 | return res_num[:-1] 128 | 129 | # categories 和 brand is all attribute 130 | def get_attribute_Amazon(meta_infos, datamaps, attribute_core): 131 | 132 | attributes = defaultdict(int) 133 | for iid, info in tqdm.tqdm(meta_infos.items()): 134 | for cates in info['categories']: 135 | for cate in cates[1:]: # 把主类删除 没有用 136 | attributes[cate] +=1 137 | try: 138 | attributes[info['brand']] += 1 139 | except: 140 | pass 141 | 142 | print(f'before delete, attribute num:{len(attributes)}') 143 | new_meta = {} 144 | for iid, info in tqdm.tqdm(meta_infos.items()): 145 | new_meta[iid] = [] 146 | 147 | try: 148 | if attributes[info['brand']] >= attribute_core: 149 | new_meta[iid].append(info['brand']) 150 | except: 151 | pass 152 | for cates in info['categories']: 153 | for cate in cates[1:]: 154 | if attributes[cate] >= attribute_core: 155 | new_meta[iid].append(cate) 156 | # 做映射 157 | attribute2id = {} 158 | id2attribute = {} 159 | attributeid2num = defaultdict(int) 160 | attribute_id = 1 161 | items2attributes = {} 162 | attribute_lens = [] 163 | 164 | for iid, attributes in new_meta.items(): 165 | item_id = datamaps['item2id'][iid] 166 | items2attributes[item_id] = [] 167 | for attribute in attributes: 168 | if attribute not in attribute2id: 169 | attribute2id[attribute] = attribute_id 170 | id2attribute[attribute_id] = attribute 171 | attribute_id += 1 172 | attributeid2num[attribute2id[attribute]] += 1 173 | items2attributes[item_id].append(attribute2id[attribute]) 174 | attribute_lens.append(len(items2attributes[item_id])) 175 | print(f'before delete, attribute num:{len(attribute2id)}') 176 | print(f'attributes len, Min:{np.min(attribute_lens)}, Max:{np.max(attribute_lens)}, Avg.:{np.mean(attribute_lens):.4f}') 177 | # 更新datamap 178 | datamaps['attribute2id'] = attribute2id 179 | datamaps['id2attribute'] = id2attribute 180 | datamaps['attributeid2num'] = attributeid2num 181 | return len(attribute2id), np.mean(attribute_lens), datamaps, items2attributes 182 | 183 | 184 | def get_attribute_Yelp(meta_infos, datamaps, attribute_core): 185 | attributes = defaultdict(int) 186 | for iid, info in tqdm.tqdm(meta_infos.items()): 187 | try: 188 | cates = [cate.strip() for cate in info['categories'].split(',')] 189 | for cate in cates: 190 | attributes[cate] +=1 191 | except: 192 | pass 193 | print(f'before delete, attribute num:{len(attributes)}') 194 | new_meta = {} 195 | for iid, info in tqdm.tqdm(meta_infos.items()): 196 | new_meta[iid] = [] 197 | try: 198 | cates = [cate.strip() for cate in info['categories'].split(',') ] 199 | for cate in cates: 200 | if attributes[cate] >= attribute_core: 201 | new_meta[iid].append(cate) 202 | except: 203 | pass 204 | # 做映射 205 | attribute2id = {} 206 | id2attribute = {} 207 | attribute_id = 1 208 | items2attributes = {} 209 | attribute_lens = [] 210 | # load id map 211 | for iid, attributes in new_meta.items(): 212 | item_id = datamaps['item2id'][iid] 213 | items2attributes[item_id] = [] 214 | for attribute in attributes: 215 | if attribute not in attribute2id: 216 | attribute2id[attribute] = attribute_id 217 | id2attribute[attribute_id] = attribute 218 | attribute_id += 1 219 | items2attributes[item_id].append(attribute2id[attribute]) 220 | attribute_lens.append(len(items2attributes[item_id])) 221 | print(f'after delete, attribute num:{len(attribute2id)}') 222 | print(f'attributes len, Min:{np.min(attribute_lens)}, Max:{np.max(attribute_lens)}, Avg.:{np.mean(attribute_lens):.4f}') 223 | # 更新datamap 224 | datamaps['attribute2id'] = attribute2id 225 | datamaps['id2attribute'] = id2attribute 226 | return len(attribute2id), np.mean(attribute_lens), datamaps, items2attributes 227 | 228 | def get_interaction(datas): 229 | user_seq = {} 230 | for data in datas: 231 | user, item, time = data 232 | if user in user_seq: 233 | user_seq[user].append((item, time)) 234 | else: 235 | user_seq[user] = [] 236 | user_seq[user].append((item, time)) 237 | 238 | for user, item_time in user_seq.items(): 239 | item_time.sort(key=lambda x: x[1]) # 对各个数据集得单独排序 240 | items = [] 241 | for t in item_time: 242 | items.append(t[0]) 243 | user_seq[user] = items 244 | return user_seq 245 | 246 | # K-core user_core item_core 247 | def check_Kcore(user_items, user_core, item_core): 248 | user_count = defaultdict(int) 249 | item_count = defaultdict(int) 250 | for user, items in user_items.items(): 251 | for item in items: 252 | user_count[user] += 1 253 | item_count[item] += 1 254 | 255 | for user, num in user_count.items(): 256 | if num < user_core: 257 | return user_count, item_count, False 258 | for item, num in item_count.items(): 259 | if num < item_core: 260 | return user_count, item_count, False 261 | return user_count, item_count, True # 已经保证Kcore 262 | 263 | # 循环过滤 K-core 264 | def filter_Kcore(user_items, user_core, item_core): # user 接所有items 265 | user_count, item_count, isKcore = check_Kcore(user_items, user_core, item_core) 266 | while not isKcore: 267 | for user, num in user_count.items(): 268 | if user_count[user] < user_core: # 直接把user 删除 269 | user_items.pop(user) 270 | else: 271 | for item in user_items[user]: 272 | if item_count[item] < item_core: 273 | user_items[user].remove(item) 274 | user_count, item_count, isKcore = check_Kcore(user_items, user_core, item_core) 275 | return user_items 276 | 277 | 278 | def id_map(user_items): # user_items dict 279 | 280 | user2id = {} # raw 2 uid 281 | item2id = {} # raw 2 iid 282 | id2user = {} # uid 2 raw 283 | id2item = {} # iid 2 raw 284 | user_id = 1 285 | item_id = 1 286 | final_data = {} 287 | for user, items in user_items.items(): 288 | if user not in user2id: 289 | user2id[user] = str(user_id) 290 | id2user[str(user_id)] = user 291 | user_id += 1 292 | iids = [] # item id lists 293 | for item in items: 294 | if item not in item2id: 295 | item2id[item] = str(item_id) 296 | id2item[str(item_id)] = item 297 | item_id += 1 298 | iids.append(item2id[item]) 299 | uid = user2id[user] 300 | final_data[uid] = iids 301 | data_maps = { 302 | 'user2id': user2id, 303 | 'item2id': item2id, 304 | 'id2user': id2user, 305 | 'id2item': id2item 306 | } 307 | return final_data, user_id-1, item_id-1, data_maps 308 | 309 | 310 | def main(data_name, data_type='Amazon'): 311 | assert data_type in {'Amazon', 'Yelp'} 312 | np.random.seed(12345) 313 | rating_score = 0.0 # rating score smaller than this score would be deleted 314 | # user 5-core item 5-core 315 | user_core = 5 316 | item_core = 5 317 | attribute_core = 0 318 | 319 | if data_type == 'Yelp': 320 | date_max = '2019-12-31 00:00:00' 321 | date_min = '2019-01-01 00:00:00' 322 | datas = Yelp(date_min, date_max, rating_score) 323 | else: 324 | datas = Amazon(data_name+'_5', rating_score=rating_score) 325 | 326 | user_items = get_interaction(datas) 327 | print(f'{data_name} Raw data has been processed! Lower than {rating_score} are deleted!') 328 | # raw_id user: [item1, item2, item3...] 329 | user_items = filter_Kcore(user_items, user_core=user_core, item_core=item_core) 330 | print(f'User {user_core}-core complete! Item {item_core}-core complete!') 331 | 332 | user_items, user_num, item_num, data_maps = id_map(user_items) # new_num_id 333 | user_count, item_count, _ = check_Kcore(user_items, user_core=user_core, item_core=item_core) 334 | user_count_list = list(user_count.values()) 335 | user_avg, user_min, user_max = np.mean(user_count_list), np.min(user_count_list), np.max(user_count_list) 336 | item_count_list = list(item_count.values()) 337 | item_avg, item_min, item_max = np.mean(item_count_list), np.min(item_count_list), np.max(item_count_list) 338 | interact_num = np.sum([x for x in user_count_list]) 339 | sparsity = (1 - interact_num / (user_num * item_num)) * 100 340 | show_info = f'Total User: {user_num}, Avg User: {user_avg:.4f}, Min Len: {user_min}, Max Len: {user_max}\n' + \ 341 | f'Total Item: {item_num}, Avg Item: {item_avg:.4f}, Min Inter: {item_min}, Max Inter: {item_max}\n' + \ 342 | f'Iteraction Num: {interact_num}, Sparsity: {sparsity:.2f}%' 343 | print(show_info) 344 | 345 | 346 | print('Begin extracting meta infos...') 347 | 348 | if data_type == 'Amazon': 349 | meta_infos = Amazon_meta(data_name, data_maps) 350 | attribute_num, avg_attribute, datamaps, item2attributes = get_attribute_Amazon(meta_infos, data_maps, attribute_core) 351 | else: 352 | meta_infos = Yelp_meta(data_maps) 353 | attribute_num, avg_attribute, datamaps, item2attributes = get_attribute_Yelp(meta_infos, data_maps, attribute_core) 354 | 355 | print(f'{data_name} & {add_comma(user_num)}& {add_comma(item_num)} & {user_avg:.1f}' 356 | f'& {item_avg:.1f}& {add_comma(interact_num)}& {sparsity:.2f}\%&{add_comma(attribute_num)}&' 357 | f'{avg_attribute:.1f} \\') 358 | 359 | # -------------- Save Data --------------- 360 | data_file = 'data/'+ data_name + '_neg.txt' 361 | item2attributes_file = 'data/'+ data_name + '_item2attributes.json' 362 | 363 | with open(data_file, 'w') as out: 364 | for user, items in user_items.items(): 365 | out.write(user + ' ' + ' '.join(items) + '\n') 366 | json_str = json.dumps(item2attributes) 367 | with open(item2attributes_file, 'w') as out: 368 | out.write(json_str) 369 | 370 | def LastFM(): 371 | user_core = 5 372 | item_core = 5 373 | datas = [] 374 | data_file = '/path/lastfm/2k/user_attributegedartists-timestamps.dat' 375 | lines = open(data_file).readlines() 376 | for line in tqdm.tqdm(lines[1:]): 377 | user, item, attribute, timestamp = line.strip().split('\t') 378 | datas.append((user, item, int(timestamp))) 379 | 380 | # 有重复item 381 | user_seq = {} 382 | user_seq_notime = {} 383 | for data in datas: 384 | user, item, time = data 385 | if user in user_seq: 386 | if item not in user_seq_notime[user]: 387 | user_seq[user].append((item, time)) 388 | user_seq_notime[user].append(item) 389 | else: 390 | continue 391 | else: 392 | user_seq[user] = [] 393 | user_seq_notime[user] = [] 394 | 395 | user_seq[user].append((item, time)) 396 | user_seq_notime[user].append(item) 397 | 398 | for user, item_time in user_seq.items(): 399 | item_time.sort(key=lambda x: x[1]) # 对各个数据集得单独排序 400 | items = [] 401 | for t in item_time: 402 | items.append(t[0]) 403 | user_seq[user] = items 404 | 405 | user_items = filter_Kcore(user_seq, user_core=user_core, item_core=item_core) 406 | print(f'User {user_core}-core complete! Item {item_core}-core complete!') 407 | 408 | user_items, user_num, item_num, data_maps = id_map(user_items) # new_num_id 409 | user_count, item_count, _ = check_Kcore(user_items, user_core=user_core, item_core=item_core) 410 | user_count_list = list(user_count.values()) 411 | user_avg, user_min, user_max = np.mean(user_count_list), np.min(user_count_list), np.max(user_count_list) 412 | item_count_list = list(item_count.values()) 413 | item_avg, item_min, item_max = np.mean(item_count_list), np.min(item_count_list), np.max(item_count_list) 414 | interact_num = np.sum([x for x in user_count_list]) 415 | sparsity = (1 - interact_num / (user_num * item_num)) * 100 416 | show_info = f'Total User: {user_num}, Avg User: {user_avg:.4f}, Min Len: {user_min}, Max Len: {user_max}\n' + \ 417 | f'Total Item: {item_num}, Avg Item: {item_avg:.4f}, Min Inter: {item_min}, Max Inter: {item_max}\n' + \ 418 | f'Iteraction Num: {interact_num}, Sparsity: {sparsity:.2f}%' 419 | print(show_info) 420 | 421 | attribute_file = './data_path/artist2attributes.json' 422 | 423 | meta_item2attribute = json.loads(open(attribute_file).readline()) 424 | 425 | # 做映射 426 | attribute2id = {} 427 | id2attribute = {} 428 | attribute_id = 1 429 | item2attributes = {} 430 | attribute_lens = [] 431 | # load id map 432 | for iid, attributes in meta_item2attribute.items(): 433 | if iid in list(data_maps['item2id'].keys()): 434 | item_id = data_maps['item2id'][iid] 435 | item2attributes[item_id] = [] 436 | for attribute in attributes: 437 | if attribute not in attribute2id: 438 | attribute2id[attribute] = attribute_id 439 | id2attribute[attribute_id] = attribute 440 | attribute_id += 1 441 | item2attributes[item_id].append(attribute2id[attribute]) 442 | attribute_lens.append(len(item2attributes[item_id])) 443 | print(f'after delete, attribute num:{len(attribute2id)}') 444 | print(f'attributes len, Min:{np.min(attribute_lens)}, Max:{np.max(attribute_lens)}, Avg.:{np.mean(attribute_lens):.4f}') 445 | # 更新datamap 446 | data_maps['attribute2id'] = attribute2id 447 | data_maps['id2attribute'] = id2attribute 448 | 449 | data_name = 'LastFM' 450 | print(f'{data_name} & {add_comma(user_num)}& {add_comma(item_num)} & {user_avg:.1f}' 451 | f'& {item_avg:.1f}& {add_comma(interact_num)}& {sparsity:.2f}\%&{add_comma(len(attribute2id))}&' 452 | f'{np.mean(attribute_lens):.1f} \\') 453 | 454 | # -------------- Save Data --------------- 455 | # one user one line 456 | data_file = 'data/' + data_name + '.txt' 457 | item2attributes_file = 'data/' + data_name + '_item2attributes.json' 458 | 459 | with open(data_file, 'w') as out: 460 | for user, items in user_items.items(): 461 | out.write(user + ' ' + ' '.join(items) + '\n') 462 | 463 | json_str = json.dumps(item2attributes) 464 | with open(item2attributes_file, 'w') as out: 465 | out.write(json_str) 466 | 467 | amazon_datas = ['Beauty', 'Sports_and_Outdoors', 'Toys_and_Games'] 468 | 469 | for name in amazon_datas: 470 | main(name, data_type='Amazon') 471 | main('Yelp', data_type='Yelp') 472 | LastFM() -------------------------------------------------------------------------------- /data/generate_test.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @Time : 2020/11/6 15:51 3 | # @Author : Hui Wang 4 | 5 | import numpy as np 6 | from collections import defaultdict 7 | 8 | np.random.seed(12345) 9 | 10 | def sample_test_data(data_name, test_num=99, sample_type='random'): 11 | """ 12 | sample_type: 13 | random: sample `test_num` negative items randomly. 14 | pop: sample `test_num` negative items according to item popularity. 15 | """ 16 | 17 | data_file = f'{data_name}.txt' 18 | test_file = f'{data_name}_sample.txt' 19 | 20 | item_count = defaultdict(int) 21 | user_items = defaultdict() 22 | 23 | lines = open(data_file).readlines() 24 | for line in lines: 25 | user, items = line.strip().split(' ', 1) 26 | items = items.split(' ') 27 | items = [int(item) for item in items] 28 | user_items[user] = items 29 | for item in items: 30 | item_count[item] += 1 31 | 32 | all_item = list(item_count.keys()) 33 | count = list(item_count.values()) 34 | sum_value = np.sum([x for x in count]) 35 | probability = [value / sum_value for value in count] 36 | 37 | user_neg_items = defaultdict() 38 | 39 | for user, user_seq in user_items.items(): 40 | test_samples = [] 41 | while len(test_samples) < test_num: 42 | if sample_type == 'random': 43 | sample_ids = np.random.choice(all_item, test_num, replace=False) 44 | else: # sample_type == 'pop': 45 | sample_ids = np.random.choice(all_item, test_num, replace=False, p=probability) 46 | sample_ids = [str(item) for item in sample_ids if item not in user_seq and item not in test_samples] 47 | test_samples.extend(sample_ids) 48 | test_samples = test_samples[:test_num] 49 | user_neg_items[user] = test_samples 50 | 51 | with open(test_file, 'w') as out: 52 | for user, samples in user_neg_items.items(): 53 | out.write(user+' '+' '.join(samples)+'\n') 54 | 55 | data_names = ['Beauty', 'Sports_and_Outdoors', 'Toys_and_Games', 'Yelp', 'LastFM'] 56 | for data_name in data_names: 57 | sample_test_data(data_name) -------------------------------------------------------------------------------- /datasets.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | import torch 4 | from torch.utils.data import Dataset 5 | 6 | from utils import neg_sample 7 | 8 | class PretrainDataset(Dataset): 9 | 10 | def __init__(self, args, user_seq, long_sequence): 11 | self.args = args 12 | self.user_seq = user_seq 13 | self.long_sequence = long_sequence 14 | self.max_len = args.max_seq_length 15 | self.part_sequence = [] 16 | self.split_sequence() 17 | 18 | def split_sequence(self): 19 | for seq in self.user_seq: 20 | input_ids = seq[-(self.max_len+2):-2] # keeping same as train set 21 | for i in range(len(input_ids)): 22 | self.part_sequence.append(input_ids[:i+1]) 23 | 24 | def __len__(self): 25 | return len(self.part_sequence) 26 | 27 | def __getitem__(self, index): 28 | 29 | sequence = self.part_sequence[index] # pos_items 30 | # sample neg item for every masked item 31 | masked_item_sequence = [] 32 | neg_items = [] 33 | # Masked Item Prediction 34 | item_set = set(sequence) 35 | for item in sequence[:-1]: 36 | prob = random.random() 37 | if prob < self.args.mask_p: 38 | masked_item_sequence.append(self.args.mask_id) 39 | neg_items.append(neg_sample(item_set, self.args.item_size)) 40 | else: 41 | masked_item_sequence.append(item) 42 | neg_items.append(item) 43 | 44 | # add mask at the last position 45 | masked_item_sequence.append(self.args.mask_id) 46 | neg_items.append(neg_sample(item_set, self.args.item_size)) 47 | 48 | # Segment Prediction 49 | if len(sequence) < 2: 50 | masked_segment_sequence = sequence 51 | pos_segment = sequence 52 | neg_segment = sequence 53 | else: 54 | sample_length = random.randint(1, len(sequence) // 2) 55 | start_id = random.randint(0, len(sequence) - sample_length) 56 | neg_start_id = random.randint(0, len(self.long_sequence) - sample_length) 57 | pos_segment = sequence[start_id: start_id + sample_length] 58 | neg_segment = self.long_sequence[neg_start_id:neg_start_id + sample_length] 59 | masked_segment_sequence = sequence[:start_id] + [self.args.mask_id] * sample_length + sequence[ 60 | start_id + sample_length:] 61 | pos_segment = [self.args.mask_id] * start_id + pos_segment + [self.args.mask_id] * ( 62 | len(sequence) - (start_id + sample_length)) 63 | neg_segment = [self.args.mask_id] * start_id + neg_segment + [self.args.mask_id] * ( 64 | len(sequence) - (start_id + sample_length)) 65 | 66 | assert len(masked_segment_sequence) == len(sequence) 67 | assert len(pos_segment) == len(sequence) 68 | assert len(neg_segment) == len(sequence) 69 | 70 | # padding sequence 71 | pad_len = self.max_len - len(sequence) 72 | masked_item_sequence = [0] * pad_len + masked_item_sequence 73 | pos_items = [0] * pad_len + sequence 74 | neg_items = [0] * pad_len + neg_items 75 | masked_segment_sequence = [0]*pad_len + masked_segment_sequence 76 | pos_segment = [0]*pad_len + pos_segment 77 | neg_segment = [0]*pad_len + neg_segment 78 | 79 | masked_item_sequence = masked_item_sequence[-self.max_len:] 80 | pos_items = pos_items[-self.max_len:] 81 | neg_items = neg_items[-self.max_len:] 82 | 83 | masked_segment_sequence = masked_segment_sequence[-self.max_len:] 84 | pos_segment = pos_segment[-self.max_len:] 85 | neg_segment = neg_segment[-self.max_len:] 86 | 87 | # Associated Attribute Prediction 88 | # Masked Attribute Prediction 89 | attributes = [] 90 | for item in pos_items: 91 | attribute = [0] * self.args.attribute_size 92 | try: 93 | now_attribute = self.args.item2attribute[str(item)] 94 | for a in now_attribute: 95 | attribute[a] = 1 96 | except: 97 | pass 98 | attributes.append(attribute) 99 | 100 | 101 | assert len(attributes) == self.max_len 102 | assert len(masked_item_sequence) == self.max_len 103 | assert len(pos_items) == self.max_len 104 | assert len(neg_items) == self.max_len 105 | assert len(masked_segment_sequence) == self.max_len 106 | assert len(pos_segment) == self.max_len 107 | assert len(neg_segment) == self.max_len 108 | 109 | 110 | cur_tensors = (torch.tensor(attributes, dtype=torch.long), 111 | torch.tensor(masked_item_sequence, dtype=torch.long), 112 | torch.tensor(pos_items, dtype=torch.long), 113 | torch.tensor(neg_items, dtype=torch.long), 114 | torch.tensor(masked_segment_sequence, dtype=torch.long), 115 | torch.tensor(pos_segment, dtype=torch.long), 116 | torch.tensor(neg_segment, dtype=torch.long),) 117 | return cur_tensors 118 | 119 | class SASRecDataset(Dataset): 120 | 121 | def __init__(self, args, user_seq, test_neg_items=None, data_type='train'): 122 | self.args = args 123 | self.user_seq = user_seq 124 | self.test_neg_items = test_neg_items 125 | self.data_type = data_type 126 | self.max_len = args.max_seq_length 127 | 128 | def __getitem__(self, index): 129 | 130 | user_id = index 131 | items = self.user_seq[index] 132 | 133 | assert self.data_type in {"train", "valid", "test"} 134 | 135 | # [0, 1, 2, 3, 4, 5, 6] 136 | # train [0, 1, 2, 3] 137 | # target [1, 2, 3, 4] 138 | 139 | # valid [0, 1, 2, 3, 4] 140 | # answer [5] 141 | 142 | # test [0, 1, 2, 3, 4, 5] 143 | # answer [6] 144 | if self.data_type == "train": 145 | input_ids = items[:-3] 146 | target_pos = items[1:-2] 147 | answer = [0] # no use 148 | 149 | elif self.data_type == 'valid': 150 | input_ids = items[:-2] 151 | target_pos = items[1:-1] 152 | answer = [items[-2]] 153 | 154 | else: 155 | input_ids = items[:-1] 156 | target_pos = items[1:] 157 | answer = [items[-1]] 158 | 159 | 160 | target_neg = [] 161 | seq_set = set(items) 162 | for _ in input_ids: 163 | target_neg.append(neg_sample(seq_set, self.args.item_size)) 164 | 165 | pad_len = self.max_len - len(input_ids) 166 | input_ids = [0] * pad_len + input_ids 167 | target_pos = [0] * pad_len + target_pos 168 | target_neg = [0] * pad_len + target_neg 169 | 170 | input_ids = input_ids[-self.max_len:] 171 | target_pos = target_pos[-self.max_len:] 172 | target_neg = target_neg[-self.max_len:] 173 | 174 | assert len(input_ids) == self.max_len 175 | assert len(target_pos) == self.max_len 176 | assert len(target_neg) == self.max_len 177 | 178 | if self.test_neg_items is not None: 179 | test_samples = self.test_neg_items[index] 180 | 181 | cur_tensors = ( 182 | torch.tensor(user_id, dtype=torch.long), # user_id for testing 183 | torch.tensor(input_ids, dtype=torch.long), 184 | torch.tensor(target_pos, dtype=torch.long), 185 | torch.tensor(target_neg, dtype=torch.long), 186 | torch.tensor(answer, dtype=torch.long), 187 | torch.tensor(test_samples, dtype=torch.long), 188 | ) 189 | else: 190 | cur_tensors = ( 191 | torch.tensor(user_id, dtype=torch.long), # user_id for testing 192 | torch.tensor(input_ids, dtype=torch.long), 193 | torch.tensor(target_pos, dtype=torch.long), 194 | torch.tensor(target_neg, dtype=torch.long), 195 | torch.tensor(answer, dtype=torch.long), 196 | ) 197 | 198 | return cur_tensors 199 | 200 | def __len__(self): 201 | return len(self.user_seq) -------------------------------------------------------------------------------- /model.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RUCAIBox/CIKM2020-S3Rec/2a81540ae18615d88ef88227b0c066e5b74781e5/model.PNG -------------------------------------------------------------------------------- /models.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @Time : 2020/3/30 10:57 3 | # @Author : Hui Wang 4 | 5 | import torch 6 | import torch.nn as nn 7 | from modules import Encoder, LayerNorm 8 | 9 | class S3RecModel(nn.Module): 10 | def __init__(self, args): 11 | super(S3RecModel, self).__init__() 12 | self.item_embeddings = nn.Embedding(args.item_size, args.hidden_size, padding_idx=0) 13 | self.attribute_embeddings = nn.Embedding(args.attribute_size, args.hidden_size, padding_idx=0) 14 | self.position_embeddings = nn.Embedding(args.max_seq_length, args.hidden_size) 15 | self.item_encoder = Encoder(args) 16 | self.LayerNorm = LayerNorm(args.hidden_size, eps=1e-12) 17 | self.dropout = nn.Dropout(args.hidden_dropout_prob) 18 | self.args = args 19 | 20 | # add unique dense layer for 4 losses respectively 21 | self.aap_norm = nn.Linear(args.hidden_size, args.hidden_size) 22 | self.mip_norm = nn.Linear(args.hidden_size, args.hidden_size) 23 | self.map_norm = nn.Linear(args.hidden_size, args.hidden_size) 24 | self.sp_norm = nn.Linear(args.hidden_size, args.hidden_size) 25 | self.criterion = nn.BCELoss(reduction='none') 26 | self.apply(self.init_weights) 27 | 28 | # AAP 29 | def associated_attribute_prediction(self, sequence_output, attribute_embedding): 30 | ''' 31 | :param sequence_output: [B L H] 32 | :param attribute_embedding: [arribute_num H] 33 | :return: scores [B*L tag_num] 34 | ''' 35 | sequence_output = self.aap_norm(sequence_output) # [B L H] 36 | sequence_output = sequence_output.view([-1, self.args.hidden_size, 1]) # [B*L H 1] 37 | # [tag_num H] [B*L H 1] -> [B*L tag_num 1] 38 | score = torch.matmul(attribute_embedding, sequence_output) 39 | return torch.sigmoid(score.squeeze(-1)) # [B*L tag_num] 40 | 41 | # MIP sample neg items 42 | def masked_item_prediction(self, sequence_output, target_item): 43 | ''' 44 | :param sequence_output: [B L H] 45 | :param target_item: [B L H] 46 | :return: scores [B*L] 47 | ''' 48 | sequence_output = self.mip_norm(sequence_output.view([-1,self.args.hidden_size])) # [B*L H] 49 | target_item = target_item.view([-1,self.args.hidden_size]) # [B*L H] 50 | score = torch.mul(sequence_output, target_item) # [B*L H] 51 | return torch.sigmoid(torch.sum(score, -1)) # [B*L] 52 | 53 | # MAP 54 | def masked_attribute_prediction(self, sequence_output, attribute_embedding): 55 | sequence_output = self.map_norm(sequence_output) # [B L H] 56 | sequence_output = sequence_output.view([-1, self.args.hidden_size, 1]) # [B*L H 1] 57 | # [tag_num H] [B*L H 1] -> [B*L tag_num 1] 58 | score = torch.matmul(attribute_embedding, sequence_output) 59 | return torch.sigmoid(score.squeeze(-1)) # [B*L tag_num] 60 | 61 | # SP sample neg segment 62 | def segment_prediction(self, context, segment): 63 | ''' 64 | :param context: [B H] 65 | :param segment: [B H] 66 | :return: 67 | ''' 68 | context = self.sp_norm(context) 69 | score = torch.mul(context, segment) # [B H] 70 | return torch.sigmoid(torch.sum(score, dim=-1)) # [B] 71 | 72 | # 73 | def add_position_embedding(self, sequence): 74 | 75 | seq_length = sequence.size(1) 76 | position_ids = torch.arange(seq_length, dtype=torch.long, device=sequence.device) 77 | position_ids = position_ids.unsqueeze(0).expand_as(sequence) 78 | item_embeddings = self.item_embeddings(sequence) 79 | position_embeddings = self.position_embeddings(position_ids) 80 | sequence_emb = item_embeddings + position_embeddings 81 | sequence_emb = self.LayerNorm(sequence_emb) 82 | sequence_emb = self.dropout(sequence_emb) 83 | 84 | return sequence_emb 85 | 86 | def pretrain(self, attributes, masked_item_sequence, pos_items, neg_items, 87 | masked_segment_sequence, pos_segment, neg_segment): 88 | 89 | # Encode masked sequence 90 | sequence_emb = self.add_position_embedding(masked_item_sequence) 91 | sequence_mask = (masked_item_sequence == 0).float() * -1e8 92 | sequence_mask = torch.unsqueeze(torch.unsqueeze(sequence_mask, 1), 1) 93 | 94 | encoded_layers = self.item_encoder(sequence_emb, 95 | sequence_mask, 96 | output_all_encoded_layers=True) 97 | # [B L H] 98 | sequence_output = encoded_layers[-1] 99 | 100 | attribute_embeddings = self.attribute_embeddings.weight 101 | # AAP 102 | aap_score = self.associated_attribute_prediction(sequence_output, attribute_embeddings) 103 | aap_loss = self.criterion(aap_score, attributes.view(-1, self.args.attribute_size).float()) 104 | # only compute loss at non-masked position 105 | aap_mask = (masked_item_sequence != self.args.mask_id).float() * \ 106 | (masked_item_sequence != 0).float() 107 | aap_loss = torch.sum(aap_loss * aap_mask.flatten().unsqueeze(-1)) 108 | 109 | # MIP 110 | pos_item_embs = self.item_embeddings(pos_items) 111 | neg_item_embs = self.item_embeddings(neg_items) 112 | pos_score = self.masked_item_prediction(sequence_output, pos_item_embs) 113 | neg_score = self.masked_item_prediction(sequence_output, neg_item_embs) 114 | mip_distance = torch.sigmoid(pos_score - neg_score) 115 | mip_loss = self.criterion(mip_distance, torch.ones_like(mip_distance, dtype=torch.float32)) 116 | mip_mask = (masked_item_sequence == self.args.mask_id).float() 117 | mip_loss = torch.sum(mip_loss * mip_mask.flatten()) 118 | 119 | # MAP 120 | map_score = self.masked_attribute_prediction(sequence_output, attribute_embeddings) 121 | map_loss = self.criterion(map_score, attributes.view(-1, self.args.attribute_size).float()) 122 | map_mask = (masked_item_sequence == self.args.mask_id).float() 123 | map_loss = torch.sum(map_loss * map_mask.flatten().unsqueeze(-1)) 124 | 125 | # SP 126 | # segment context 127 | segment_context = self.add_position_embedding(masked_segment_sequence) 128 | segment_mask = (masked_segment_sequence == 0).float() * -1e8 129 | segment_mask = torch.unsqueeze(torch.unsqueeze(segment_mask, 1), 1) 130 | segment_encoded_layers = self.item_encoder(segment_context, 131 | segment_mask, 132 | output_all_encoded_layers=True) 133 | 134 | # take the last position hidden as the context 135 | segment_context = segment_encoded_layers[-1][:, -1, :]# [B H] 136 | # pos_segment 137 | pos_segment_emb = self.add_position_embedding(pos_segment) 138 | pos_segment_mask = (pos_segment == 0).float() * -1e8 139 | pos_segment_mask = torch.unsqueeze(torch.unsqueeze(pos_segment_mask, 1), 1) 140 | pos_segment_encoded_layers = self.item_encoder(pos_segment_emb, 141 | pos_segment_mask, 142 | output_all_encoded_layers=True) 143 | pos_segment_emb = pos_segment_encoded_layers[-1][:, -1, :] 144 | 145 | # neg_segment 146 | neg_segment_emb = self.add_position_embedding(neg_segment) 147 | neg_segment_mask = (neg_segment == 0).float() * -1e8 148 | neg_segment_mask = torch.unsqueeze(torch.unsqueeze(neg_segment_mask, 1), 1) 149 | neg_segment_encoded_layers = self.item_encoder(neg_segment_emb, 150 | neg_segment_mask, 151 | output_all_encoded_layers=True) 152 | neg_segment_emb = neg_segment_encoded_layers[-1][:, -1, :] # [B H] 153 | 154 | pos_segment_score = self.segment_prediction(segment_context, pos_segment_emb) 155 | neg_segment_score = self.segment_prediction(segment_context, neg_segment_emb) 156 | 157 | sp_distance = torch.sigmoid(pos_segment_score - neg_segment_score) 158 | 159 | sp_loss = torch.sum(self.criterion(sp_distance, 160 | torch.ones_like(sp_distance, dtype=torch.float32))) 161 | 162 | return aap_loss, mip_loss, map_loss, sp_loss 163 | 164 | # Fine tune 165 | # same as SASRec 166 | def finetune(self, input_ids): 167 | 168 | attention_mask = (input_ids > 0).long() 169 | extended_attention_mask = attention_mask.unsqueeze(1).unsqueeze(2) # torch.int64 170 | max_len = attention_mask.size(-1) 171 | attn_shape = (1, max_len, max_len) 172 | subsequent_mask = torch.triu(torch.ones(attn_shape), diagonal=1) # torch.uint8 173 | subsequent_mask = (subsequent_mask == 0).unsqueeze(1) 174 | subsequent_mask = subsequent_mask.long() 175 | 176 | if self.args.cuda_condition: 177 | subsequent_mask = subsequent_mask.cuda() 178 | 179 | extended_attention_mask = extended_attention_mask * subsequent_mask 180 | extended_attention_mask = extended_attention_mask.to(dtype=next(self.parameters()).dtype) # fp16 compatibility 181 | extended_attention_mask = (1.0 - extended_attention_mask) * -10000.0 182 | 183 | sequence_emb = self.add_position_embedding(input_ids) 184 | 185 | item_encoded_layers = self.item_encoder(sequence_emb, 186 | extended_attention_mask, 187 | output_all_encoded_layers=True) 188 | 189 | sequence_output = item_encoded_layers[-1] 190 | return sequence_output 191 | 192 | def init_weights(self, module): 193 | """ Initialize the weights. 194 | """ 195 | if isinstance(module, (nn.Linear, nn.Embedding)): 196 | # Slightly different from the TF version which uses truncated_normal for initialization 197 | # cf https://github.com/pytorch/pytorch/pull/5617 198 | module.weight.data.normal_(mean=0.0, std=self.args.initializer_range) 199 | elif isinstance(module, LayerNorm): 200 | module.bias.data.zero_() 201 | module.weight.data.fill_(1.0) 202 | if isinstance(module, nn.Linear) and module.bias is not None: 203 | module.bias.data.zero_() -------------------------------------------------------------------------------- /modules.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # __author__ = 'wanghui' 3 | # __date__ = '2020/03/30 10:53' 4 | 5 | import numpy as np 6 | 7 | import copy 8 | import math 9 | import torch 10 | import torch.nn as nn 11 | import torch.nn.functional as F 12 | 13 | 14 | def gelu(x): 15 | """Implementation of the gelu activation function. 16 | For information: OpenAI GPT's gelu is slightly different 17 | (and gives slightly different results): 18 | 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * 19 | (x + 0.044715 * torch.pow(x, 3)))) 20 | Also see https://arxiv.org/abs/1606.08415 21 | """ 22 | return x * 0.5 * (1.0 + torch.erf(x / math.sqrt(2.0))) 23 | 24 | def swish(x): 25 | return x * torch.sigmoid(x) 26 | 27 | 28 | ACT2FN = {"gelu": gelu, "relu": F.relu, "swish": swish} 29 | 30 | 31 | class LayerNorm(nn.Module): 32 | def __init__(self, hidden_size, eps=1e-12): 33 | """Construct a layernorm module in the TF style (epsilon inside the square root). 34 | """ 35 | super(LayerNorm, self).__init__() 36 | self.weight = nn.Parameter(torch.ones(hidden_size)) 37 | self.bias = nn.Parameter(torch.zeros(hidden_size)) 38 | self.variance_epsilon = eps 39 | 40 | def forward(self, x): 41 | u = x.mean(-1, keepdim=True) 42 | s = (x - u).pow(2).mean(-1, keepdim=True) 43 | x = (x - u) / torch.sqrt(s + self.variance_epsilon) 44 | return self.weight * x + self.bias 45 | 46 | 47 | class Embeddings(nn.Module): 48 | """Construct the embeddings from item, position. 49 | """ 50 | def __init__(self, args): 51 | super(Embeddings, self).__init__() 52 | 53 | self.item_embeddings = nn.Embedding(args.item_size, args.hidden_size, padding_idx=0) # 不要乱用padding_idx 54 | self.position_embeddings = nn.Embedding(args.max_seq_length, args.hidden_size) 55 | 56 | self.LayerNorm = LayerNorm(args.hidden_size, eps=1e-12) 57 | self.dropout = nn.Dropout(args.hidden_dropout_prob) 58 | 59 | self.args = args 60 | 61 | def forward(self, input_ids): 62 | seq_length = input_ids.size(1) 63 | position_ids = torch.arange(seq_length, dtype=torch.long, device=input_ids.device) 64 | position_ids = position_ids.unsqueeze(0).expand_as(input_ids) 65 | items_embeddings = self.item_embeddings(input_ids) 66 | position_embeddings = self.position_embeddings(position_ids) 67 | embeddings = items_embeddings + position_embeddings 68 | # 修改属性 69 | embeddings = self.LayerNorm(embeddings) 70 | embeddings = self.dropout(embeddings) 71 | return embeddings 72 | 73 | class SelfAttention(nn.Module): 74 | def __init__(self, args): 75 | super(SelfAttention, self).__init__() 76 | if args.hidden_size % args.num_attention_heads != 0: 77 | raise ValueError( 78 | "The hidden size (%d) is not a multiple of the number of attention " 79 | "heads (%d)" % (args.hidden_size, args.num_attention_heads)) 80 | self.num_attention_heads = args.num_attention_heads 81 | self.attention_head_size = int(args.hidden_size / args.num_attention_heads) 82 | self.all_head_size = self.num_attention_heads * self.attention_head_size 83 | 84 | self.query = nn.Linear(args.hidden_size, self.all_head_size) 85 | self.key = nn.Linear(args.hidden_size, self.all_head_size) 86 | self.value = nn.Linear(args.hidden_size, self.all_head_size) 87 | 88 | self.attn_dropout = nn.Dropout(args.attention_probs_dropout_prob) 89 | 90 | # 做完self-attention 做一个前馈全连接 LayerNorm 输出 91 | self.dense = nn.Linear(args.hidden_size, args.hidden_size) 92 | self.LayerNorm = LayerNorm(args.hidden_size, eps=1e-12) 93 | self.out_dropout = nn.Dropout(args.hidden_dropout_prob) 94 | 95 | def transpose_for_scores(self, x): 96 | new_x_shape = x.size()[:-1] + (self.num_attention_heads, self.attention_head_size) 97 | x = x.view(*new_x_shape) 98 | return x.permute(0, 2, 1, 3) 99 | 100 | def forward(self, input_tensor, attention_mask): 101 | mixed_query_layer = self.query(input_tensor) 102 | mixed_key_layer = self.key(input_tensor) 103 | mixed_value_layer = self.value(input_tensor) 104 | 105 | query_layer = self.transpose_for_scores(mixed_query_layer) 106 | key_layer = self.transpose_for_scores(mixed_key_layer) 107 | value_layer = self.transpose_for_scores(mixed_value_layer) 108 | 109 | # Take the dot product between "query" and "key" to get the raw attention scores. 110 | attention_scores = torch.matmul(query_layer, key_layer.transpose(-1, -2)) 111 | 112 | attention_scores = attention_scores / math.sqrt(self.attention_head_size) 113 | # Apply the attention mask is (precomputed for all layers in BertModel forward() function) 114 | # [batch_size heads seq_len seq_len] scores 115 | # [batch_size 1 1 seq_len] 116 | attention_scores = attention_scores + attention_mask 117 | 118 | # Normalize the attention scores to probabilities. 119 | attention_probs = nn.Softmax(dim=-1)(attention_scores) 120 | # This is actually dropping out entire tokens to attend to, which might 121 | # seem a bit unusual, but is taken from the original Transformer paper. 122 | # Fixme 123 | attention_probs = self.attn_dropout(attention_probs) 124 | context_layer = torch.matmul(attention_probs, value_layer) 125 | context_layer = context_layer.permute(0, 2, 1, 3).contiguous() 126 | new_context_layer_shape = context_layer.size()[:-2] + (self.all_head_size,) 127 | context_layer = context_layer.view(*new_context_layer_shape) 128 | hidden_states = self.dense(context_layer) 129 | hidden_states = self.out_dropout(hidden_states) 130 | hidden_states = self.LayerNorm(hidden_states + input_tensor) 131 | 132 | return hidden_states 133 | 134 | 135 | class Intermediate(nn.Module): 136 | def __init__(self, args): 137 | super(Intermediate, self).__init__() 138 | self.dense_1 = nn.Linear(args.hidden_size, args.hidden_size * 4) 139 | if isinstance(args.hidden_act, str): 140 | self.intermediate_act_fn = ACT2FN[args.hidden_act] 141 | else: 142 | self.intermediate_act_fn = args.hidden_act 143 | 144 | self.dense_2 = nn.Linear(args.hidden_size * 4, args.hidden_size) 145 | self.LayerNorm = LayerNorm(args.hidden_size, eps=1e-12) 146 | self.dropout = nn.Dropout(args.hidden_dropout_prob) 147 | 148 | 149 | def forward(self, input_tensor): 150 | 151 | hidden_states = self.dense_1(input_tensor) 152 | hidden_states = self.intermediate_act_fn(hidden_states) 153 | 154 | hidden_states = self.dense_2(hidden_states) 155 | hidden_states = self.dropout(hidden_states) 156 | hidden_states = self.LayerNorm(hidden_states + input_tensor) 157 | 158 | return hidden_states 159 | 160 | 161 | class Layer(nn.Module): 162 | def __init__(self, args): 163 | super(Layer, self).__init__() 164 | self.attention = SelfAttention(args) 165 | self.intermediate = Intermediate(args) 166 | 167 | def forward(self, hidden_states, attention_mask): 168 | attention_output = self.attention(hidden_states, attention_mask) 169 | intermediate_output = self.intermediate(attention_output) 170 | return intermediate_output 171 | 172 | 173 | class Encoder(nn.Module): 174 | def __init__(self, args): 175 | super(Encoder, self).__init__() 176 | layer = Layer(args) 177 | self.layer = nn.ModuleList([copy.deepcopy(layer) 178 | for _ in range(args.num_hidden_layers)]) 179 | 180 | def forward(self, hidden_states, attention_mask, output_all_encoded_layers=True): 181 | all_encoder_layers = [] 182 | for layer_module in self.layer: 183 | hidden_states = layer_module(hidden_states, attention_mask) 184 | if output_all_encoded_layers: 185 | all_encoder_layers.append(hidden_states) 186 | if not output_all_encoded_layers: 187 | all_encoder_layers.append(hidden_states) 188 | return all_encoder_layers -------------------------------------------------------------------------------- /reproduce/Beauty-epochs-150.pt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RUCAIBox/CIKM2020-S3Rec/2a81540ae18615d88ef88227b0c066e5b74781e5/reproduce/Beauty-epochs-150.pt -------------------------------------------------------------------------------- /reproduce/Finetune_sample-Beauty-150.txt: -------------------------------------------------------------------------------- 1 | Namespace(adam_beta1=0.9, adam_beta2=0.999, attention_probs_dropout_prob=0.5, attribute_size=638, batch_size=256, ckp=150, cuda_condition=True, data_dir='../TOIS/data/', data_file='../TOIS/data/Beauty.txt', data_name='Beauty', do_eval=False, epochs=200, gpu_id='0', hidden_act='gelu', hidden_dropout_prob=0.5, hidden_size=64, initializer_range=0.02, item_size=12103, log_file='output/Finetune_sample-Beauty-150.txt', log_freq=1, lr=0.001, mask_id=12102, max_seq_length=50, model_name='Finetune_sample', no_cuda=False, num_attention_heads=2, num_hidden_layers=2, output_dir='output/', sample_file='../TOIS/data/Beauty_sample.txt', seed=42, weight_decay=0.0) 2 | {'epoch': 0, 'rec_avg_loss': '1.0469', 'rec_cur_loss': '0.9528'} 3 | {'Epoch': 0, 'HIT@1': '0.1753', 'NDCG@1': '0.1753', 'HIT@5': '0.4217', 'NDCG@5': '0.3031', 'HIT@10': '0.5440', 'NDCG@10': '0.3427', 'MRR': '0.2971'} 4 | {'epoch': 1, 'rec_avg_loss': '0.9020', 'rec_cur_loss': '0.8269'} 5 | {'Epoch': 1, 'HIT@1': '0.1921', 'NDCG@1': '0.1921', 'HIT@5': '0.4452', 'NDCG@5': '0.3243', 'HIT@10': '0.5638', 'NDCG@10': '0.3627', 'MRR': '0.3163'} 6 | {'epoch': 2, 'rec_avg_loss': '0.8543', 'rec_cur_loss': '0.8734'} 7 | {'Epoch': 2, 'HIT@1': '0.2045', 'NDCG@1': '0.2045', 'HIT@5': '0.4574', 'NDCG@5': '0.3368', 'HIT@10': '0.5725', 'NDCG@10': '0.3740', 'MRR': '0.3281'} 8 | {'epoch': 3, 'rec_avg_loss': '0.8276', 'rec_cur_loss': '0.8171'} 9 | {'Epoch': 3, 'HIT@1': '0.2124', 'NDCG@1': '0.2124', 'HIT@5': '0.4656', 'NDCG@5': '0.3448', 'HIT@10': '0.5774', 'NDCG@10': '0.3810', 'MRR': '0.3354'} 10 | {'epoch': 4, 'rec_avg_loss': '0.8052', 'rec_cur_loss': '0.7592'} 11 | {'Epoch': 4, 'HIT@1': '0.2181', 'NDCG@1': '0.2181', 'HIT@5': '0.4693', 'NDCG@5': '0.3496', 'HIT@10': '0.5822', 'NDCG@10': '0.3861', 'MRR': '0.3405'} 12 | {'epoch': 5, 'rec_avg_loss': '0.7920', 'rec_cur_loss': '0.8306'} 13 | {'Epoch': 5, 'HIT@1': '0.2233', 'NDCG@1': '0.2233', 'HIT@5': '0.4720', 'NDCG@5': '0.3536', 'HIT@10': '0.5849', 'NDCG@10': '0.3901', 'MRR': '0.3447'} 14 | {'epoch': 6, 'rec_avg_loss': '0.7796', 'rec_cur_loss': '0.7360'} 15 | {'Epoch': 6, 'HIT@1': '0.2256', 'NDCG@1': '0.2256', 'HIT@5': '0.4758', 'NDCG@5': '0.3573', 'HIT@10': '0.5878', 'NDCG@10': '0.3936', 'MRR': '0.3482'} 16 | {'epoch': 7, 'rec_avg_loss': '0.7671', 'rec_cur_loss': '0.7359'} 17 | {'Epoch': 7, 'HIT@1': '0.2287', 'NDCG@1': '0.2287', 'HIT@5': '0.4787', 'NDCG@5': '0.3601', 'HIT@10': '0.5883', 'NDCG@10': '0.3955', 'MRR': '0.3505'} 18 | {'epoch': 8, 'rec_avg_loss': '0.7596', 'rec_cur_loss': '0.8514'} 19 | {'Epoch': 8, 'HIT@1': '0.2308', 'NDCG@1': '0.2308', 'HIT@5': '0.4797', 'NDCG@5': '0.3618', 'HIT@10': '0.5888', 'NDCG@10': '0.3971', 'MRR': '0.3524'} 20 | {'epoch': 9, 'rec_avg_loss': '0.7490', 'rec_cur_loss': '0.7336'} 21 | {'Epoch': 9, 'HIT@1': '0.2301', 'NDCG@1': '0.2301', 'HIT@5': '0.4796', 'NDCG@5': '0.3615', 'HIT@10': '0.5894', 'NDCG@10': '0.3970', 'MRR': '0.3521'} 22 | {'epoch': 10, 'rec_avg_loss': '0.7401', 'rec_cur_loss': '0.7711'} 23 | {'Epoch': 10, 'HIT@1': '0.2332', 'NDCG@1': '0.2332', 'HIT@5': '0.4858', 'NDCG@5': '0.3658', 'HIT@10': '0.5908', 'NDCG@10': '0.3996', 'MRR': '0.3551'} 24 | {'epoch': 11, 'rec_avg_loss': '0.7341', 'rec_cur_loss': '0.6732'} 25 | {'Epoch': 11, 'HIT@1': '0.2341', 'NDCG@1': '0.2341', 'HIT@5': '0.4845', 'NDCG@5': '0.3660', 'HIT@10': '0.5925', 'NDCG@10': '0.4008', 'MRR': '0.3560'} 26 | {'epoch': 12, 'rec_avg_loss': '0.7295', 'rec_cur_loss': '0.7621'} 27 | {'Epoch': 12, 'HIT@1': '0.2344', 'NDCG@1': '0.2344', 'HIT@5': '0.4850', 'NDCG@5': '0.3663', 'HIT@10': '0.5920', 'NDCG@10': '0.4009', 'MRR': '0.3564'} 28 | {'epoch': 13, 'rec_avg_loss': '0.7241', 'rec_cur_loss': '0.6654'} 29 | {'Epoch': 13, 'HIT@1': '0.2367', 'NDCG@1': '0.2367', 'HIT@5': '0.4859', 'NDCG@5': '0.3678', 'HIT@10': '0.5927', 'NDCG@10': '0.4022', 'MRR': '0.3578'} 30 | {'epoch': 14, 'rec_avg_loss': '0.7181', 'rec_cur_loss': '0.6980'} 31 | {'Epoch': 14, 'HIT@1': '0.2421', 'NDCG@1': '0.2421', 'HIT@5': '0.4872', 'NDCG@5': '0.3711', 'HIT@10': '0.5943', 'NDCG@10': '0.4056', 'MRR': '0.3617'} 32 | {'epoch': 15, 'rec_avg_loss': '0.7121', 'rec_cur_loss': '0.6765'} 33 | {'Epoch': 15, 'HIT@1': '0.2407', 'NDCG@1': '0.2407', 'HIT@5': '0.4877', 'NDCG@5': '0.3710', 'HIT@10': '0.5935', 'NDCG@10': '0.4052', 'MRR': '0.3613'} 34 | {'epoch': 16, 'rec_avg_loss': '0.7061', 'rec_cur_loss': '0.5843'} 35 | {'Epoch': 16, 'HIT@1': '0.2408', 'NDCG@1': '0.2408', 'HIT@5': '0.4890', 'NDCG@5': '0.3716', 'HIT@10': '0.5940', 'NDCG@10': '0.4056', 'MRR': '0.3617'} 36 | {'epoch': 17, 'rec_avg_loss': '0.6993', 'rec_cur_loss': '0.7112'} 37 | {'Epoch': 17, 'HIT@1': '0.2445', 'NDCG@1': '0.2445', 'HIT@5': '0.4899', 'NDCG@5': '0.3740', 'HIT@10': '0.5938', 'NDCG@10': '0.4076', 'MRR': '0.3644'} 38 | {'epoch': 18, 'rec_avg_loss': '0.6922', 'rec_cur_loss': '0.6654'} 39 | {'Epoch': 18, 'HIT@1': '0.2430', 'NDCG@1': '0.2430', 'HIT@5': '0.4877', 'NDCG@5': '0.3724', 'HIT@10': '0.5944', 'NDCG@10': '0.4069', 'MRR': '0.3634'} 40 | {'epoch': 19, 'rec_avg_loss': '0.6891', 'rec_cur_loss': '0.6543'} 41 | {'Epoch': 19, 'HIT@1': '0.2442', 'NDCG@1': '0.2442', 'HIT@5': '0.4887', 'NDCG@5': '0.3737', 'HIT@10': '0.5953', 'NDCG@10': '0.4081', 'MRR': '0.3647'} 42 | {'epoch': 20, 'rec_avg_loss': '0.6817', 'rec_cur_loss': '0.5738'} 43 | {'Epoch': 20, 'HIT@1': '0.2472', 'NDCG@1': '0.2472', 'HIT@5': '0.4882', 'NDCG@5': '0.3746', 'HIT@10': '0.5955', 'NDCG@10': '0.4094', 'MRR': '0.3663'} 44 | {'epoch': 21, 'rec_avg_loss': '0.6782', 'rec_cur_loss': '0.6411'} 45 | {'Epoch': 21, 'HIT@1': '0.2454', 'NDCG@1': '0.2454', 'HIT@5': '0.4905', 'NDCG@5': '0.3748', 'HIT@10': '0.5953', 'NDCG@10': '0.4087', 'MRR': '0.3655'} 46 | {'epoch': 22, 'rec_avg_loss': '0.6759', 'rec_cur_loss': '0.6503'} 47 | {'Epoch': 22, 'HIT@1': '0.2472', 'NDCG@1': '0.2472', 'HIT@5': '0.4901', 'NDCG@5': '0.3758', 'HIT@10': '0.5947', 'NDCG@10': '0.4098', 'MRR': '0.3671'} 48 | {'epoch': 23, 'rec_avg_loss': '0.6699', 'rec_cur_loss': '0.6127'} 49 | {'Epoch': 23, 'HIT@1': '0.2471', 'NDCG@1': '0.2471', 'HIT@5': '0.4896', 'NDCG@5': '0.3752', 'HIT@10': '0.5962', 'NDCG@10': '0.4096', 'MRR': '0.3664'} 50 | {'epoch': 24, 'rec_avg_loss': '0.6660', 'rec_cur_loss': '0.6421'} 51 | {'Epoch': 24, 'HIT@1': '0.2476', 'NDCG@1': '0.2476', 'HIT@5': '0.4900', 'NDCG@5': '0.3755', 'HIT@10': '0.5969', 'NDCG@10': '0.4101', 'MRR': '0.3668'} 52 | {'epoch': 25, 'rec_avg_loss': '0.6636', 'rec_cur_loss': '0.6368'} 53 | {'Epoch': 25, 'HIT@1': '0.2472', 'NDCG@1': '0.2472', 'HIT@5': '0.4920', 'NDCG@5': '0.3764', 'HIT@10': '0.5959', 'NDCG@10': '0.4100', 'MRR': '0.3670'} 54 | {'epoch': 26, 'rec_avg_loss': '0.6594', 'rec_cur_loss': '0.6627'} 55 | {'Epoch': 26, 'HIT@1': '0.2489', 'NDCG@1': '0.2489', 'HIT@5': '0.4934', 'NDCG@5': '0.3781', 'HIT@10': '0.5957', 'NDCG@10': '0.4112', 'MRR': '0.3685'} 56 | {'epoch': 27, 'rec_avg_loss': '0.6540', 'rec_cur_loss': '0.7094'} 57 | {'Epoch': 27, 'HIT@1': '0.2491', 'NDCG@1': '0.2491', 'HIT@5': '0.4933', 'NDCG@5': '0.3783', 'HIT@10': '0.5971', 'NDCG@10': '0.4119', 'MRR': '0.3689'} 58 | {'epoch': 28, 'rec_avg_loss': '0.6494', 'rec_cur_loss': '0.7687'} 59 | {'Epoch': 28, 'HIT@1': '0.2493', 'NDCG@1': '0.2493', 'HIT@5': '0.4934', 'NDCG@5': '0.3785', 'HIT@10': '0.5973', 'NDCG@10': '0.4121', 'MRR': '0.3692'} 60 | {'epoch': 29, 'rec_avg_loss': '0.6473', 'rec_cur_loss': '0.6763'} 61 | {'Epoch': 29, 'HIT@1': '0.2516', 'NDCG@1': '0.2516', 'HIT@5': '0.4941', 'NDCG@5': '0.3794', 'HIT@10': '0.5961', 'NDCG@10': '0.4124', 'MRR': '0.3700'} 62 | {'epoch': 30, 'rec_avg_loss': '0.6427', 'rec_cur_loss': '0.6223'} 63 | {'Epoch': 30, 'HIT@1': '0.2505', 'NDCG@1': '0.2505', 'HIT@5': '0.4945', 'NDCG@5': '0.3795', 'HIT@10': '0.5975', 'NDCG@10': '0.4128', 'MRR': '0.3699'} 64 | {'epoch': 31, 'rec_avg_loss': '0.6398', 'rec_cur_loss': '0.6585'} 65 | {'Epoch': 31, 'HIT@1': '0.2517', 'NDCG@1': '0.2517', 'HIT@5': '0.4955', 'NDCG@5': '0.3804', 'HIT@10': '0.5971', 'NDCG@10': '0.4132', 'MRR': '0.3707'} 66 | {'epoch': 32, 'rec_avg_loss': '0.6344', 'rec_cur_loss': '0.7227'} 67 | {'Epoch': 32, 'HIT@1': '0.2510', 'NDCG@1': '0.2510', 'HIT@5': '0.4949', 'NDCG@5': '0.3800', 'HIT@10': '0.5984', 'NDCG@10': '0.4134', 'MRR': '0.3704'} 68 | {'epoch': 33, 'rec_avg_loss': '0.6302', 'rec_cur_loss': '0.6889'} 69 | {'Epoch': 33, 'HIT@1': '0.2519', 'NDCG@1': '0.2519', 'HIT@5': '0.4953', 'NDCG@5': '0.3802', 'HIT@10': '0.5964', 'NDCG@10': '0.4128', 'MRR': '0.3704'} 70 | {'epoch': 34, 'rec_avg_loss': '0.6295', 'rec_cur_loss': '0.6754'} 71 | {'Epoch': 34, 'HIT@1': '0.2544', 'NDCG@1': '0.2544', 'HIT@5': '0.4946', 'NDCG@5': '0.3815', 'HIT@10': '0.5987', 'NDCG@10': '0.4151', 'MRR': '0.3726'} 72 | {'epoch': 35, 'rec_avg_loss': '0.6193', 'rec_cur_loss': '0.6089'} 73 | {'Epoch': 35, 'HIT@1': '0.2538', 'NDCG@1': '0.2538', 'HIT@5': '0.4946', 'NDCG@5': '0.3811', 'HIT@10': '0.5975', 'NDCG@10': '0.4144', 'MRR': '0.3722'} 74 | {'epoch': 36, 'rec_avg_loss': '0.6164', 'rec_cur_loss': '0.5571'} 75 | {'Epoch': 36, 'HIT@1': '0.2548', 'NDCG@1': '0.2548', 'HIT@5': '0.4943', 'NDCG@5': '0.3816', 'HIT@10': '0.5973', 'NDCG@10': '0.4149', 'MRR': '0.3729'} 76 | {'epoch': 37, 'rec_avg_loss': '0.6140', 'rec_cur_loss': '0.5679'} 77 | {'Epoch': 37, 'HIT@1': '0.2550', 'NDCG@1': '0.2550', 'HIT@5': '0.4943', 'NDCG@5': '0.3815', 'HIT@10': '0.5968', 'NDCG@10': '0.4145', 'MRR': '0.3726'} 78 | {'epoch': 38, 'rec_avg_loss': '0.6141', 'rec_cur_loss': '0.6280'} 79 | {'Epoch': 38, 'HIT@1': '0.2534', 'NDCG@1': '0.2534', 'HIT@5': '0.4946', 'NDCG@5': '0.3808', 'HIT@10': '0.5976', 'NDCG@10': '0.4142', 'MRR': '0.3718'} 80 | {'epoch': 39, 'rec_avg_loss': '0.6099', 'rec_cur_loss': '0.5916'} 81 | {'Epoch': 39, 'HIT@1': '0.2544', 'NDCG@1': '0.2544', 'HIT@5': '0.4941', 'NDCG@5': '0.3813', 'HIT@10': '0.5970', 'NDCG@10': '0.4146', 'MRR': '0.3725'} 82 | {'epoch': 40, 'rec_avg_loss': '0.6092', 'rec_cur_loss': '0.6684'} 83 | {'Epoch': 40, 'HIT@1': '0.2549', 'NDCG@1': '0.2549', 'HIT@5': '0.4922', 'NDCG@5': '0.3807', 'HIT@10': '0.5980', 'NDCG@10': '0.4149', 'MRR': '0.3726'} 84 | {'epoch': 41, 'rec_avg_loss': '0.6048', 'rec_cur_loss': '0.6717'} 85 | {'Epoch': 41, 'HIT@1': '0.2538', 'NDCG@1': '0.2538', 'HIT@5': '0.4933', 'NDCG@5': '0.3805', 'HIT@10': '0.5960', 'NDCG@10': '0.4137', 'MRR': '0.3718'} 86 | {'epoch': 42, 'rec_avg_loss': '0.6003', 'rec_cur_loss': '0.5697'} 87 | {'Epoch': 42, 'HIT@1': '0.2555', 'NDCG@1': '0.2555', 'HIT@5': '0.4963', 'NDCG@5': '0.3828', 'HIT@10': '0.5992', 'NDCG@10': '0.4160', 'MRR': '0.3735'} 88 | {'epoch': 43, 'rec_avg_loss': '0.5981', 'rec_cur_loss': '0.5534'} 89 | {'Epoch': 43, 'HIT@1': '0.2555', 'NDCG@1': '0.2555', 'HIT@5': '0.4934', 'NDCG@5': '0.3818', 'HIT@10': '0.5949', 'NDCG@10': '0.4146', 'MRR': '0.3734'} 90 | {'epoch': 44, 'rec_avg_loss': '0.5949', 'rec_cur_loss': '0.6100'} 91 | {'Epoch': 44, 'HIT@1': '0.2556', 'NDCG@1': '0.2556', 'HIT@5': '0.4951', 'NDCG@5': '0.3825', 'HIT@10': '0.5967', 'NDCG@10': '0.4153', 'MRR': '0.3735'} 92 | {'epoch': 45, 'rec_avg_loss': '0.5954', 'rec_cur_loss': '0.6158'} 93 | {'Epoch': 45, 'HIT@1': '0.2561', 'NDCG@1': '0.2561', 'HIT@5': '0.4936', 'NDCG@5': '0.3820', 'HIT@10': '0.5963', 'NDCG@10': '0.4152', 'MRR': '0.3735'} 94 | {'epoch': 46, 'rec_avg_loss': '0.5907', 'rec_cur_loss': '0.5856'} 95 | {'Epoch': 46, 'HIT@1': '0.2561', 'NDCG@1': '0.2561', 'HIT@5': '0.4943', 'NDCG@5': '0.3824', 'HIT@10': '0.5953', 'NDCG@10': '0.4150', 'MRR': '0.3737'} 96 | {'epoch': 47, 'rec_avg_loss': '0.5900', 'rec_cur_loss': '0.6170'} 97 | {'Epoch': 47, 'HIT@1': '0.2556', 'NDCG@1': '0.2556', 'HIT@5': '0.4943', 'NDCG@5': '0.3822', 'HIT@10': '0.5954', 'NDCG@10': '0.4149', 'MRR': '0.3735'} 98 | {'epoch': 48, 'rec_avg_loss': '0.5830', 'rec_cur_loss': '0.5279'} 99 | {'Epoch': 48, 'HIT@1': '0.2575', 'NDCG@1': '0.2575', 'HIT@5': '0.4932', 'NDCG@5': '0.3825', 'HIT@10': '0.5965', 'NDCG@10': '0.4158', 'MRR': '0.3743'} 100 | {'epoch': 49, 'rec_avg_loss': '0.5814', 'rec_cur_loss': '0.6069'} 101 | {'Epoch': 49, 'HIT@1': '0.2565', 'NDCG@1': '0.2565', 'HIT@5': '0.4929', 'NDCG@5': '0.3823', 'HIT@10': '0.5943', 'NDCG@10': '0.4151', 'MRR': '0.3741'} 102 | {'epoch': 50, 'rec_avg_loss': '0.5779', 'rec_cur_loss': '0.5970'} 103 | {'Epoch': 50, 'HIT@1': '0.2572', 'NDCG@1': '0.2572', 'HIT@5': '0.4928', 'NDCG@5': '0.3824', 'HIT@10': '0.5961', 'NDCG@10': '0.4158', 'MRR': '0.3744'} 104 | {'epoch': 51, 'rec_avg_loss': '0.5782', 'rec_cur_loss': '0.5809'} 105 | {'Epoch': 51, 'HIT@1': '0.2586', 'NDCG@1': '0.2586', 'HIT@5': '0.4936', 'NDCG@5': '0.3833', 'HIT@10': '0.5977', 'NDCG@10': '0.4169', 'MRR': '0.3752'} 106 | {'epoch': 52, 'rec_avg_loss': '0.5732', 'rec_cur_loss': '0.6743'} 107 | {'Epoch': 52, 'HIT@1': '0.2566', 'NDCG@1': '0.2566', 'HIT@5': '0.4936', 'NDCG@5': '0.3826', 'HIT@10': '0.5951', 'NDCG@10': '0.4154', 'MRR': '0.3742'} 108 | {'epoch': 53, 'rec_avg_loss': '0.5716', 'rec_cur_loss': '0.5335'} 109 | {'Epoch': 53, 'HIT@1': '0.2545', 'NDCG@1': '0.2545', 'HIT@5': '0.4934', 'NDCG@5': '0.3815', 'HIT@10': '0.5966', 'NDCG@10': '0.4147', 'MRR': '0.3728'} 110 | {'epoch': 54, 'rec_avg_loss': '0.5718', 'rec_cur_loss': '0.5240'} 111 | {'Epoch': 54, 'HIT@1': '0.2570', 'NDCG@1': '0.2570', 'HIT@5': '0.4934', 'NDCG@5': '0.3829', 'HIT@10': '0.5947', 'NDCG@10': '0.4156', 'MRR': '0.3747'} 112 | {'epoch': 55, 'rec_avg_loss': '0.5684', 'rec_cur_loss': '0.5723'} 113 | {'Epoch': 55, 'HIT@1': '0.2565', 'NDCG@1': '0.2565', 'HIT@5': '0.4917', 'NDCG@5': '0.3818', 'HIT@10': '0.5968', 'NDCG@10': '0.4158', 'MRR': '0.3741'} 114 | {'epoch': 56, 'rec_avg_loss': '0.5678', 'rec_cur_loss': '0.5397'} 115 | {'Epoch': 56, 'HIT@1': '0.2553', 'NDCG@1': '0.2553', 'HIT@5': '0.4909', 'NDCG@5': '0.3808', 'HIT@10': '0.5943', 'NDCG@10': '0.4142', 'MRR': '0.3730'} 116 | {'epoch': 57, 'rec_avg_loss': '0.5637', 'rec_cur_loss': '0.5759'} 117 | {'Epoch': 57, 'HIT@1': '0.2551', 'NDCG@1': '0.2551', 'HIT@5': '0.4918', 'NDCG@5': '0.3811', 'HIT@10': '0.5950', 'NDCG@10': '0.4144', 'MRR': '0.3730'} 118 | {'epoch': 58, 'rec_avg_loss': '0.5641', 'rec_cur_loss': '0.6579'} 119 | {'Epoch': 58, 'HIT@1': '0.2594', 'NDCG@1': '0.2594', 'HIT@5': '0.4906', 'NDCG@5': '0.3823', 'HIT@10': '0.5947', 'NDCG@10': '0.4159', 'MRR': '0.3751'} 120 | {'epoch': 59, 'rec_avg_loss': '0.5543', 'rec_cur_loss': '0.6234'} 121 | {'Epoch': 59, 'HIT@1': '0.2560', 'NDCG@1': '0.2560', 'HIT@5': '0.4923', 'NDCG@5': '0.3815', 'HIT@10': '0.5952', 'NDCG@10': '0.4147', 'MRR': '0.3733'} 122 | {'epoch': 60, 'rec_avg_loss': '0.5541', 'rec_cur_loss': '0.5116'} 123 | {'Epoch': 60, 'HIT@1': '0.2568', 'NDCG@1': '0.2568', 'HIT@5': '0.4906', 'NDCG@5': '0.3810', 'HIT@10': '0.5946', 'NDCG@10': '0.4147', 'MRR': '0.3735'} 124 | {'epoch': 61, 'rec_avg_loss': '0.5488', 'rec_cur_loss': '0.5453'} 125 | {'Epoch': 61, 'HIT@1': '0.2568', 'NDCG@1': '0.2568', 'HIT@5': '0.4898', 'NDCG@5': '0.3810', 'HIT@10': '0.5943', 'NDCG@10': '0.4148', 'MRR': '0.3738'} 126 | {'Epoch': 0, 'HIT@1': '0.2197', 'NDCG@1': '0.2197', 'HIT@5': '0.4626', 'NDCG@5': '0.3473', 'HIT@10': '0.5687', 'NDCG@10': '0.3816', 'MRR': '0.3390'} 127 | Finetune_sample-Beauty-150 128 | {'Epoch': 0, 'HIT@1': '0.2197', 'NDCG@1': '0.2197', 'HIT@5': '0.4626', 'NDCG@5': '0.3473', 'HIT@10': '0.5687', 'NDCG@10': '0.3816', 'MRR': '0.3390'} 129 | -------------------------------------------------------------------------------- /reproduce/Finetune_sample-LastFM-0.txt: -------------------------------------------------------------------------------- 1 | Namespace(adam_beta1=0.9, adam_beta2=0.999, attention_probs_dropout_prob=0.5, attribute_size=389, batch_size=256, ckp=0, cuda_condition=True, data_dir='../TOIS/data/', data_file='../TOIS/data/LastFM.txt', data_name='LastFM', do_eval=False, epochs=200, gpu_id='2', hidden_act='gelu', hidden_dropout_prob=0.5, hidden_size=64, initializer_range=0.02, item_size=3648, log_file='output/Finetune_sample-LastFM-0.txt', log_freq=1, lr=0.001, mask_id=3647, max_seq_length=50, model_name='Finetune_sample', no_cuda=False, num_attention_heads=2, num_hidden_layers=2, output_dir='output/', sample_file='../TOIS/data/LastFM_sample.txt', seed=42, weight_decay=0.0) 2 | {'epoch': 0, 'rec_avg_loss': '1.3933', 'rec_cur_loss': '1.3972'} 3 | {'Epoch': 0, 'HIT@1': '0.0092', 'NDCG@1': '0.0092', 'HIT@5': '0.0532', 'NDCG@5': '0.0309', 'HIT@10': '0.1165', 'NDCG@10': '0.0512', 'MRR': '0.0549'} 4 | {'epoch': 1, 'rec_avg_loss': '1.3757', 'rec_cur_loss': '1.3697'} 5 | {'Epoch': 1, 'HIT@1': '0.0147', 'NDCG@1': '0.0147', 'HIT@5': '0.0615', 'NDCG@5': '0.0372', 'HIT@10': '0.1284', 'NDCG@10': '0.0588', 'MRR': '0.0610'} 6 | {'epoch': 2, 'rec_avg_loss': '1.3642', 'rec_cur_loss': '1.3612'} 7 | {'Epoch': 2, 'HIT@1': '0.0211', 'NDCG@1': '0.0211', 'HIT@5': '0.0734', 'NDCG@5': '0.0462', 'HIT@10': '0.1376', 'NDCG@10': '0.0670', 'MRR': '0.0691'} 8 | {'epoch': 3, 'rec_avg_loss': '1.3497', 'rec_cur_loss': '1.3478'} 9 | {'Epoch': 3, 'HIT@1': '0.0275', 'NDCG@1': '0.0275', 'HIT@5': '0.0963', 'NDCG@5': '0.0628', 'HIT@10': '0.1661', 'NDCG@10': '0.0849', 'MRR': '0.0837'} 10 | {'epoch': 4, 'rec_avg_loss': '1.3293', 'rec_cur_loss': '1.3202'} 11 | {'Epoch': 4, 'HIT@1': '0.0495', 'NDCG@1': '0.0495', 'HIT@5': '0.1514', 'NDCG@5': '0.1003', 'HIT@10': '0.2248', 'NDCG@10': '0.1239', 'MRR': '0.1150'} 12 | {'epoch': 5, 'rec_avg_loss': '1.3010', 'rec_cur_loss': '1.2849'} 13 | {'Epoch': 5, 'HIT@1': '0.0706', 'NDCG@1': '0.0706', 'HIT@5': '0.1890', 'NDCG@5': '0.1327', 'HIT@10': '0.2752', 'NDCG@10': '0.1603', 'MRR': '0.1463'} 14 | {'epoch': 6, 'rec_avg_loss': '1.2783', 'rec_cur_loss': '1.2670'} 15 | {'Epoch': 6, 'HIT@1': '0.0771', 'NDCG@1': '0.0771', 'HIT@5': '0.2083', 'NDCG@5': '0.1448', 'HIT@10': '0.2982', 'NDCG@10': '0.1736', 'MRR': '0.1562'} 16 | {'epoch': 7, 'rec_avg_loss': '1.2495', 'rec_cur_loss': '1.2339'} 17 | {'Epoch': 7, 'HIT@1': '0.0734', 'NDCG@1': '0.0734', 'HIT@5': '0.2147', 'NDCG@5': '0.1469', 'HIT@10': '0.3110', 'NDCG@10': '0.1779', 'MRR': '0.1578'} 18 | {'epoch': 8, 'rec_avg_loss': '1.2236', 'rec_cur_loss': '1.2062'} 19 | {'Epoch': 8, 'HIT@1': '0.0771', 'NDCG@1': '0.0771', 'HIT@5': '0.2128', 'NDCG@5': '0.1473', 'HIT@10': '0.3165', 'NDCG@10': '0.1807', 'MRR': '0.1601'} 20 | {'epoch': 9, 'rec_avg_loss': '1.1965', 'rec_cur_loss': '1.1590'} 21 | {'Epoch': 9, 'HIT@1': '0.0752', 'NDCG@1': '0.0752', 'HIT@5': '0.2174', 'NDCG@5': '0.1484', 'HIT@10': '0.3284', 'NDCG@10': '0.1840', 'MRR': '0.1603'} 22 | {'epoch': 10, 'rec_avg_loss': '1.1802', 'rec_cur_loss': '1.1797'} 23 | {'Epoch': 10, 'HIT@1': '0.0716', 'NDCG@1': '0.0716', 'HIT@5': '0.2193', 'NDCG@5': '0.1473', 'HIT@10': '0.3257', 'NDCG@10': '0.1814', 'MRR': '0.1581'} 24 | {'epoch': 11, 'rec_avg_loss': '1.1625', 'rec_cur_loss': '1.1501'} 25 | {'Epoch': 11, 'HIT@1': '0.0761', 'NDCG@1': '0.0761', 'HIT@5': '0.2174', 'NDCG@5': '0.1489', 'HIT@10': '0.3358', 'NDCG@10': '0.1866', 'MRR': '0.1616'} 26 | {'epoch': 12, 'rec_avg_loss': '1.1462', 'rec_cur_loss': '1.1533'} 27 | {'Epoch': 12, 'HIT@1': '0.0771', 'NDCG@1': '0.0771', 'HIT@5': '0.2220', 'NDCG@5': '0.1508', 'HIT@10': '0.3394', 'NDCG@10': '0.1883', 'MRR': '0.1626'} 28 | {'epoch': 13, 'rec_avg_loss': '1.1264', 'rec_cur_loss': '1.1115'} 29 | {'Epoch': 13, 'HIT@1': '0.0734', 'NDCG@1': '0.0734', 'HIT@5': '0.2257', 'NDCG@5': '0.1512', 'HIT@10': '0.3294', 'NDCG@10': '0.1846', 'MRR': '0.1614'} 30 | {'epoch': 14, 'rec_avg_loss': '1.1114', 'rec_cur_loss': '1.0762'} 31 | {'Epoch': 14, 'HIT@1': '0.0761', 'NDCG@1': '0.0761', 'HIT@5': '0.2229', 'NDCG@5': '0.1511', 'HIT@10': '0.3339', 'NDCG@10': '0.1866', 'MRR': '0.1624'} 32 | {'epoch': 15, 'rec_avg_loss': '1.1058', 'rec_cur_loss': '1.1072'} 33 | {'Epoch': 15, 'HIT@1': '0.0734', 'NDCG@1': '0.0734', 'HIT@5': '0.2257', 'NDCG@5': '0.1512', 'HIT@10': '0.3284', 'NDCG@10': '0.1840', 'MRR': '0.1609'} 34 | {'epoch': 16, 'rec_avg_loss': '1.0903', 'rec_cur_loss': '1.0775'} 35 | {'Epoch': 16, 'HIT@1': '0.0716', 'NDCG@1': '0.0716', 'HIT@5': '0.2266', 'NDCG@5': '0.1499', 'HIT@10': '0.3321', 'NDCG@10': '0.1837', 'MRR': '0.1590'} 36 | {'epoch': 17, 'rec_avg_loss': '1.0813', 'rec_cur_loss': '1.0848'} 37 | {'Epoch': 17, 'HIT@1': '0.0725', 'NDCG@1': '0.0725', 'HIT@5': '0.2284', 'NDCG@5': '0.1509', 'HIT@10': '0.3303', 'NDCG@10': '0.1837', 'MRR': '0.1596'} 38 | {'epoch': 18, 'rec_avg_loss': '1.0695', 'rec_cur_loss': '1.0711'} 39 | {'Epoch': 18, 'HIT@1': '0.0716', 'NDCG@1': '0.0716', 'HIT@5': '0.2294', 'NDCG@5': '0.1515', 'HIT@10': '0.3312', 'NDCG@10': '0.1840', 'MRR': '0.1598'} 40 | {'epoch': 19, 'rec_avg_loss': '1.0504', 'rec_cur_loss': '1.0119'} 41 | {'Epoch': 19, 'HIT@1': '0.0706', 'NDCG@1': '0.0706', 'HIT@5': '0.2312', 'NDCG@5': '0.1518', 'HIT@10': '0.3330', 'NDCG@10': '0.1841', 'MRR': '0.1595'} 42 | {'epoch': 20, 'rec_avg_loss': '1.0544', 'rec_cur_loss': '1.0692'} 43 | {'Epoch': 20, 'HIT@1': '0.0725', 'NDCG@1': '0.0725', 'HIT@5': '0.2349', 'NDCG@5': '0.1546', 'HIT@10': '0.3275', 'NDCG@10': '0.1842', 'MRR': '0.1616'} 44 | {'epoch': 21, 'rec_avg_loss': '1.0358', 'rec_cur_loss': '1.0099'} 45 | {'Epoch': 21, 'HIT@1': '0.0716', 'NDCG@1': '0.0716', 'HIT@5': '0.2321', 'NDCG@5': '0.1540', 'HIT@10': '0.3349', 'NDCG@10': '0.1868', 'MRR': '0.1623'} 46 | {'epoch': 22, 'rec_avg_loss': '1.0255', 'rec_cur_loss': '1.0040'} 47 | {'Epoch': 22, 'HIT@1': '0.0752', 'NDCG@1': '0.0752', 'HIT@5': '0.2330', 'NDCG@5': '0.1563', 'HIT@10': '0.3385', 'NDCG@10': '0.1900', 'MRR': '0.1654'} 48 | {'epoch': 23, 'rec_avg_loss': '1.0301', 'rec_cur_loss': '1.0684'} 49 | {'Epoch': 23, 'HIT@1': '0.0798', 'NDCG@1': '0.0798', 'HIT@5': '0.2339', 'NDCG@5': '0.1584', 'HIT@10': '0.3358', 'NDCG@10': '0.1910', 'MRR': '0.1680'} 50 | {'epoch': 24, 'rec_avg_loss': '1.0080', 'rec_cur_loss': '1.0028'} 51 | {'Epoch': 24, 'HIT@1': '0.0817', 'NDCG@1': '0.0817', 'HIT@5': '0.2367', 'NDCG@5': '0.1607', 'HIT@10': '0.3468', 'NDCG@10': '0.1960', 'MRR': '0.1707'} 52 | {'epoch': 25, 'rec_avg_loss': '1.0004', 'rec_cur_loss': '1.0081'} 53 | {'Epoch': 25, 'HIT@1': '0.0826', 'NDCG@1': '0.0826', 'HIT@5': '0.2422', 'NDCG@5': '0.1642', 'HIT@10': '0.3468', 'NDCG@10': '0.1977', 'MRR': '0.1731'} 54 | {'epoch': 26, 'rec_avg_loss': '0.9939', 'rec_cur_loss': '1.0026'} 55 | {'Epoch': 26, 'HIT@1': '0.0826', 'NDCG@1': '0.0826', 'HIT@5': '0.2459', 'NDCG@5': '0.1669', 'HIT@10': '0.3468', 'NDCG@10': '0.1993', 'MRR': '0.1754'} 56 | {'epoch': 27, 'rec_avg_loss': '0.9751', 'rec_cur_loss': '0.9681'} 57 | {'Epoch': 27, 'HIT@1': '0.0844', 'NDCG@1': '0.0844', 'HIT@5': '0.2541', 'NDCG@5': '0.1717', 'HIT@10': '0.3550', 'NDCG@10': '0.2037', 'MRR': '0.1785'} 58 | {'epoch': 28, 'rec_avg_loss': '0.9705', 'rec_cur_loss': '0.9901'} 59 | {'Epoch': 28, 'HIT@1': '0.0862', 'NDCG@1': '0.0862', 'HIT@5': '0.2560', 'NDCG@5': '0.1733', 'HIT@10': '0.3615', 'NDCG@10': '0.2068', 'MRR': '0.1804'} 60 | {'epoch': 29, 'rec_avg_loss': '0.9622', 'rec_cur_loss': '0.9722'} 61 | {'Epoch': 29, 'HIT@1': '0.0844', 'NDCG@1': '0.0844', 'HIT@5': '0.2615', 'NDCG@5': '0.1748', 'HIT@10': '0.3697', 'NDCG@10': '0.2093', 'MRR': '0.1807'} 62 | {'epoch': 30, 'rec_avg_loss': '0.9517', 'rec_cur_loss': '0.9457'} 63 | {'Epoch': 30, 'HIT@1': '0.0917', 'NDCG@1': '0.0917', 'HIT@5': '0.2697', 'NDCG@5': '0.1817', 'HIT@10': '0.3734', 'NDCG@10': '0.2146', 'MRR': '0.1865'} 64 | {'epoch': 31, 'rec_avg_loss': '0.9504', 'rec_cur_loss': '0.9937'} 65 | {'Epoch': 31, 'HIT@1': '0.0936', 'NDCG@1': '0.0936', 'HIT@5': '0.2734', 'NDCG@5': '0.1836', 'HIT@10': '0.3743', 'NDCG@10': '0.2158', 'MRR': '0.1881'} 66 | {'epoch': 32, 'rec_avg_loss': '0.9265', 'rec_cur_loss': '0.9120'} 67 | {'Epoch': 32, 'HIT@1': '0.0945', 'NDCG@1': '0.0945', 'HIT@5': '0.2697', 'NDCG@5': '0.1822', 'HIT@10': '0.3835', 'NDCG@10': '0.2186', 'MRR': '0.1888'} 68 | {'epoch': 33, 'rec_avg_loss': '0.9182', 'rec_cur_loss': '0.8787'} 69 | {'Epoch': 33, 'HIT@1': '0.0972', 'NDCG@1': '0.0972', 'HIT@5': '0.2743', 'NDCG@5': '0.1862', 'HIT@10': '0.3872', 'NDCG@10': '0.2223', 'MRR': '0.1924'} 70 | {'epoch': 34, 'rec_avg_loss': '0.9111', 'rec_cur_loss': '0.9111'} 71 | {'Epoch': 34, 'HIT@1': '0.0982', 'NDCG@1': '0.0982', 'HIT@5': '0.2807', 'NDCG@5': '0.1900', 'HIT@10': '0.3899', 'NDCG@10': '0.2249', 'MRR': '0.1951'} 72 | {'epoch': 35, 'rec_avg_loss': '0.9023', 'rec_cur_loss': '0.8896'} 73 | {'Epoch': 35, 'HIT@1': '0.0927', 'NDCG@1': '0.0927', 'HIT@5': '0.2881', 'NDCG@5': '0.1921', 'HIT@10': '0.3890', 'NDCG@10': '0.2243', 'MRR': '0.1945'} 74 | {'epoch': 36, 'rec_avg_loss': '0.8878', 'rec_cur_loss': '0.8557'} 75 | {'Epoch': 36, 'HIT@1': '0.0991', 'NDCG@1': '0.0991', 'HIT@5': '0.2826', 'NDCG@5': '0.1922', 'HIT@10': '0.3963', 'NDCG@10': '0.2285', 'MRR': '0.1976'} 76 | {'epoch': 37, 'rec_avg_loss': '0.8853', 'rec_cur_loss': '0.8809'} 77 | {'Epoch': 37, 'HIT@1': '0.1000', 'NDCG@1': '0.1000', 'HIT@5': '0.2844', 'NDCG@5': '0.1942', 'HIT@10': '0.4000', 'NDCG@10': '0.2311', 'MRR': '0.1997'} 78 | {'epoch': 38, 'rec_avg_loss': '0.8733', 'rec_cur_loss': '0.8725'} 79 | {'Epoch': 38, 'HIT@1': '0.1018', 'NDCG@1': '0.1018', 'HIT@5': '0.2872', 'NDCG@5': '0.1967', 'HIT@10': '0.4009', 'NDCG@10': '0.2330', 'MRR': '0.2020'} 80 | {'epoch': 39, 'rec_avg_loss': '0.8668', 'rec_cur_loss': '0.8559'} 81 | {'Epoch': 39, 'HIT@1': '0.1028', 'NDCG@1': '0.1028', 'HIT@5': '0.2908', 'NDCG@5': '0.1992', 'HIT@10': '0.4083', 'NDCG@10': '0.2366', 'MRR': '0.2041'} 82 | {'epoch': 40, 'rec_avg_loss': '0.8632', 'rec_cur_loss': '0.8892'} 83 | {'Epoch': 40, 'HIT@1': '0.1073', 'NDCG@1': '0.1073', 'HIT@5': '0.2936', 'NDCG@5': '0.2017', 'HIT@10': '0.4138', 'NDCG@10': '0.2400', 'MRR': '0.2068'} 84 | {'epoch': 41, 'rec_avg_loss': '0.8487', 'rec_cur_loss': '0.8536'} 85 | {'Epoch': 41, 'HIT@1': '0.1119', 'NDCG@1': '0.1119', 'HIT@5': '0.3009', 'NDCG@5': '0.2084', 'HIT@10': '0.4165', 'NDCG@10': '0.2450', 'MRR': '0.2123'} 86 | {'epoch': 42, 'rec_avg_loss': '0.8420', 'rec_cur_loss': '0.8499'} 87 | {'Epoch': 42, 'HIT@1': '0.1037', 'NDCG@1': '0.1037', 'HIT@5': '0.3000', 'NDCG@5': '0.2054', 'HIT@10': '0.4138', 'NDCG@10': '0.2417', 'MRR': '0.2089'} 88 | {'epoch': 43, 'rec_avg_loss': '0.8307', 'rec_cur_loss': '0.8214'} 89 | {'Epoch': 43, 'HIT@1': '0.1009', 'NDCG@1': '0.1009', 'HIT@5': '0.3064', 'NDCG@5': '0.2064', 'HIT@10': '0.4156', 'NDCG@10': '0.2412', 'MRR': '0.2078'} 90 | {'epoch': 44, 'rec_avg_loss': '0.8336', 'rec_cur_loss': '0.8702'} 91 | {'Epoch': 44, 'HIT@1': '0.1055', 'NDCG@1': '0.1055', 'HIT@5': '0.3028', 'NDCG@5': '0.2069', 'HIT@10': '0.4202', 'NDCG@10': '0.2447', 'MRR': '0.2107'} 92 | {'epoch': 45, 'rec_avg_loss': '0.8154', 'rec_cur_loss': '0.8038'} 93 | {'Epoch': 45, 'HIT@1': '0.1037', 'NDCG@1': '0.1037', 'HIT@5': '0.3083', 'NDCG@5': '0.2099', 'HIT@10': '0.4156', 'NDCG@10': '0.2443', 'MRR': '0.2118'} 94 | {'epoch': 46, 'rec_avg_loss': '0.8117', 'rec_cur_loss': '0.8310'} 95 | {'Epoch': 46, 'HIT@1': '0.1083', 'NDCG@1': '0.1083', 'HIT@5': '0.3083', 'NDCG@5': '0.2120', 'HIT@10': '0.4183', 'NDCG@10': '0.2469', 'MRR': '0.2144'} 96 | {'epoch': 47, 'rec_avg_loss': '0.7915', 'rec_cur_loss': '0.7293'} 97 | {'Epoch': 47, 'HIT@1': '0.1083', 'NDCG@1': '0.1083', 'HIT@5': '0.3083', 'NDCG@5': '0.2116', 'HIT@10': '0.4193', 'NDCG@10': '0.2469', 'MRR': '0.2145'} 98 | {'epoch': 48, 'rec_avg_loss': '0.7933', 'rec_cur_loss': '0.7945'} 99 | {'Epoch': 48, 'HIT@1': '0.1083', 'NDCG@1': '0.1083', 'HIT@5': '0.3110', 'NDCG@5': '0.2133', 'HIT@10': '0.4248', 'NDCG@10': '0.2495', 'MRR': '0.2160'} 100 | {'epoch': 49, 'rec_avg_loss': '0.7903', 'rec_cur_loss': '0.7961'} 101 | {'Epoch': 49, 'HIT@1': '0.1101', 'NDCG@1': '0.1101', 'HIT@5': '0.3138', 'NDCG@5': '0.2154', 'HIT@10': '0.4312', 'NDCG@10': '0.2528', 'MRR': '0.2183'} 102 | {'epoch': 50, 'rec_avg_loss': '0.7815', 'rec_cur_loss': '0.7854'} 103 | {'Epoch': 50, 'HIT@1': '0.1119', 'NDCG@1': '0.1119', 'HIT@5': '0.3156', 'NDCG@5': '0.2172', 'HIT@10': '0.4330', 'NDCG@10': '0.2546', 'MRR': '0.2201'} 104 | {'epoch': 51, 'rec_avg_loss': '0.7788', 'rec_cur_loss': '0.7918'} 105 | {'Epoch': 51, 'HIT@1': '0.1174', 'NDCG@1': '0.1174', 'HIT@5': '0.3147', 'NDCG@5': '0.2182', 'HIT@10': '0.4303', 'NDCG@10': '0.2550', 'MRR': '0.2218'} 106 | {'epoch': 52, 'rec_avg_loss': '0.7649', 'rec_cur_loss': '0.7590'} 107 | {'Epoch': 52, 'HIT@1': '0.1211', 'NDCG@1': '0.1211', 'HIT@5': '0.3128', 'NDCG@5': '0.2193', 'HIT@10': '0.4321', 'NDCG@10': '0.2575', 'MRR': '0.2247'} 108 | {'epoch': 53, 'rec_avg_loss': '0.7657', 'rec_cur_loss': '0.7829'} 109 | {'Epoch': 53, 'HIT@1': '0.1183', 'NDCG@1': '0.1183', 'HIT@5': '0.3183', 'NDCG@5': '0.2204', 'HIT@10': '0.4349', 'NDCG@10': '0.2579', 'MRR': '0.2242'} 110 | {'epoch': 54, 'rec_avg_loss': '0.7503', 'rec_cur_loss': '0.7352'} 111 | {'Epoch': 54, 'HIT@1': '0.1202', 'NDCG@1': '0.1202', 'HIT@5': '0.3229', 'NDCG@5': '0.2226', 'HIT@10': '0.4321', 'NDCG@10': '0.2576', 'MRR': '0.2250'} 112 | {'epoch': 55, 'rec_avg_loss': '0.7423', 'rec_cur_loss': '0.7384'} 113 | {'Epoch': 55, 'HIT@1': '0.1193', 'NDCG@1': '0.1193', 'HIT@5': '0.3257', 'NDCG@5': '0.2242', 'HIT@10': '0.4394', 'NDCG@10': '0.2607', 'MRR': '0.2264'} 114 | {'epoch': 56, 'rec_avg_loss': '0.7412', 'rec_cur_loss': '0.7295'} 115 | {'Epoch': 56, 'HIT@1': '0.1183', 'NDCG@1': '0.1183', 'HIT@5': '0.3239', 'NDCG@5': '0.2238', 'HIT@10': '0.4450', 'NDCG@10': '0.2627', 'MRR': '0.2271'} 116 | {'epoch': 57, 'rec_avg_loss': '0.7334', 'rec_cur_loss': '0.7426'} 117 | {'Epoch': 57, 'HIT@1': '0.1220', 'NDCG@1': '0.1220', 'HIT@5': '0.3193', 'NDCG@5': '0.2239', 'HIT@10': '0.4486', 'NDCG@10': '0.2655', 'MRR': '0.2295'} 118 | {'epoch': 58, 'rec_avg_loss': '0.7293', 'rec_cur_loss': '0.7301'} 119 | {'Epoch': 58, 'HIT@1': '0.1193', 'NDCG@1': '0.1193', 'HIT@5': '0.3202', 'NDCG@5': '0.2229', 'HIT@10': '0.4532', 'NDCG@10': '0.2658', 'MRR': '0.2283'} 120 | {'epoch': 59, 'rec_avg_loss': '0.7206', 'rec_cur_loss': '0.7259'} 121 | {'Epoch': 59, 'HIT@1': '0.1165', 'NDCG@1': '0.1165', 'HIT@5': '0.3229', 'NDCG@5': '0.2235', 'HIT@10': '0.4569', 'NDCG@10': '0.2665', 'MRR': '0.2278'} 122 | {'epoch': 60, 'rec_avg_loss': '0.7160', 'rec_cur_loss': '0.7162'} 123 | {'Epoch': 60, 'HIT@1': '0.1147', 'NDCG@1': '0.1147', 'HIT@5': '0.3239', 'NDCG@5': '0.2230', 'HIT@10': '0.4596', 'NDCG@10': '0.2667', 'MRR': '0.2271'} 124 | {'epoch': 61, 'rec_avg_loss': '0.7062', 'rec_cur_loss': '0.6871'} 125 | {'Epoch': 61, 'HIT@1': '0.1147', 'NDCG@1': '0.1147', 'HIT@5': '0.3275', 'NDCG@5': '0.2250', 'HIT@10': '0.4624', 'NDCG@10': '0.2682', 'MRR': '0.2283'} 126 | {'epoch': 62, 'rec_avg_loss': '0.7023', 'rec_cur_loss': '0.7010'} 127 | {'Epoch': 62, 'HIT@1': '0.1147', 'NDCG@1': '0.1147', 'HIT@5': '0.3248', 'NDCG@5': '0.2245', 'HIT@10': '0.4624', 'NDCG@10': '0.2688', 'MRR': '0.2291'} 128 | {'epoch': 63, 'rec_avg_loss': '0.6953', 'rec_cur_loss': '0.7044'} 129 | {'Epoch': 63, 'HIT@1': '0.1193', 'NDCG@1': '0.1193', 'HIT@5': '0.3266', 'NDCG@5': '0.2261', 'HIT@10': '0.4587', 'NDCG@10': '0.2688', 'MRR': '0.2307'} 130 | {'epoch': 64, 'rec_avg_loss': '0.6942', 'rec_cur_loss': '0.7083'} 131 | {'Epoch': 64, 'HIT@1': '0.1211', 'NDCG@1': '0.1211', 'HIT@5': '0.3339', 'NDCG@5': '0.2297', 'HIT@10': '0.4651', 'NDCG@10': '0.2720', 'MRR': '0.2325'} 132 | {'epoch': 65, 'rec_avg_loss': '0.6777', 'rec_cur_loss': '0.6647'} 133 | {'Epoch': 65, 'HIT@1': '0.1229', 'NDCG@1': '0.1229', 'HIT@5': '0.3339', 'NDCG@5': '0.2311', 'HIT@10': '0.4670', 'NDCG@10': '0.2739', 'MRR': '0.2343'} 134 | {'epoch': 66, 'rec_avg_loss': '0.6780', 'rec_cur_loss': '0.6961'} 135 | {'Epoch': 66, 'HIT@1': '0.1220', 'NDCG@1': '0.1220', 'HIT@5': '0.3358', 'NDCG@5': '0.2320', 'HIT@10': '0.4651', 'NDCG@10': '0.2737', 'MRR': '0.2348'} 136 | {'epoch': 67, 'rec_avg_loss': '0.6698', 'rec_cur_loss': '0.6687'} 137 | {'Epoch': 67, 'HIT@1': '0.1248', 'NDCG@1': '0.1248', 'HIT@5': '0.3349', 'NDCG@5': '0.2317', 'HIT@10': '0.4651', 'NDCG@10': '0.2738', 'MRR': '0.2351'} 138 | {'epoch': 68, 'rec_avg_loss': '0.6663', 'rec_cur_loss': '0.6590'} 139 | {'Epoch': 68, 'HIT@1': '0.1220', 'NDCG@1': '0.1220', 'HIT@5': '0.3367', 'NDCG@5': '0.2315', 'HIT@10': '0.4661', 'NDCG@10': '0.2733', 'MRR': '0.2339'} 140 | {'epoch': 69, 'rec_avg_loss': '0.6552', 'rec_cur_loss': '0.6439'} 141 | {'Epoch': 69, 'HIT@1': '0.1174', 'NDCG@1': '0.1174', 'HIT@5': '0.3422', 'NDCG@5': '0.2327', 'HIT@10': '0.4716', 'NDCG@10': '0.2745', 'MRR': '0.2332'} 142 | {'epoch': 70, 'rec_avg_loss': '0.6559', 'rec_cur_loss': '0.6417'} 143 | {'Epoch': 70, 'HIT@1': '0.1229', 'NDCG@1': '0.1229', 'HIT@5': '0.3422', 'NDCG@5': '0.2349', 'HIT@10': '0.4734', 'NDCG@10': '0.2772', 'MRR': '0.2365'} 144 | {'epoch': 71, 'rec_avg_loss': '0.6495', 'rec_cur_loss': '0.6508'} 145 | {'Epoch': 71, 'HIT@1': '0.1257', 'NDCG@1': '0.1257', 'HIT@5': '0.3468', 'NDCG@5': '0.2384', 'HIT@10': '0.4734', 'NDCG@10': '0.2790', 'MRR': '0.2391'} 146 | {'epoch': 72, 'rec_avg_loss': '0.6446', 'rec_cur_loss': '0.6265'} 147 | {'Epoch': 72, 'HIT@1': '0.1257', 'NDCG@1': '0.1257', 'HIT@5': '0.3486', 'NDCG@5': '0.2390', 'HIT@10': '0.4771', 'NDCG@10': '0.2804', 'MRR': '0.2396'} 148 | {'epoch': 73, 'rec_avg_loss': '0.6425', 'rec_cur_loss': '0.6490'} 149 | {'Epoch': 73, 'HIT@1': '0.1266', 'NDCG@1': '0.1266', 'HIT@5': '0.3486', 'NDCG@5': '0.2398', 'HIT@10': '0.4789', 'NDCG@10': '0.2817', 'MRR': '0.2407'} 150 | {'epoch': 74, 'rec_avg_loss': '0.6361', 'rec_cur_loss': '0.6487'} 151 | {'Epoch': 74, 'HIT@1': '0.1229', 'NDCG@1': '0.1229', 'HIT@5': '0.3532', 'NDCG@5': '0.2410', 'HIT@10': '0.4789', 'NDCG@10': '0.2812', 'MRR': '0.2397'} 152 | {'epoch': 75, 'rec_avg_loss': '0.6288', 'rec_cur_loss': '0.6257'} 153 | {'Epoch': 75, 'HIT@1': '0.1284', 'NDCG@1': '0.1284', 'HIT@5': '0.3560', 'NDCG@5': '0.2452', 'HIT@10': '0.4752', 'NDCG@10': '0.2835', 'MRR': '0.2441'} 154 | {'epoch': 76, 'rec_avg_loss': '0.6236', 'rec_cur_loss': '0.6138'} 155 | {'Epoch': 76, 'HIT@1': '0.1275', 'NDCG@1': '0.1275', 'HIT@5': '0.3523', 'NDCG@5': '0.2438', 'HIT@10': '0.4771', 'NDCG@10': '0.2843', 'MRR': '0.2445'} 156 | {'epoch': 77, 'rec_avg_loss': '0.6179', 'rec_cur_loss': '0.6089'} 157 | {'Epoch': 77, 'HIT@1': '0.1275', 'NDCG@1': '0.1275', 'HIT@5': '0.3523', 'NDCG@5': '0.2438', 'HIT@10': '0.4798', 'NDCG@10': '0.2851', 'MRR': '0.2446'} 158 | {'epoch': 78, 'rec_avg_loss': '0.6162', 'rec_cur_loss': '0.6318'} 159 | {'Epoch': 78, 'HIT@1': '0.1321', 'NDCG@1': '0.1321', 'HIT@5': '0.3541', 'NDCG@5': '0.2469', 'HIT@10': '0.4798', 'NDCG@10': '0.2872', 'MRR': '0.2477'} 160 | {'epoch': 79, 'rec_avg_loss': '0.6087', 'rec_cur_loss': '0.6167'} 161 | {'Epoch': 79, 'HIT@1': '0.1294', 'NDCG@1': '0.1294', 'HIT@5': '0.3550', 'NDCG@5': '0.2472', 'HIT@10': '0.4844', 'NDCG@10': '0.2888', 'MRR': '0.2479'} 162 | {'epoch': 80, 'rec_avg_loss': '0.6055', 'rec_cur_loss': '0.6328'} 163 | {'Epoch': 80, 'HIT@1': '0.1303', 'NDCG@1': '0.1303', 'HIT@5': '0.3560', 'NDCG@5': '0.2470', 'HIT@10': '0.4872', 'NDCG@10': '0.2892', 'MRR': '0.2475'} 164 | {'epoch': 81, 'rec_avg_loss': '0.6035', 'rec_cur_loss': '0.6050'} 165 | {'Epoch': 81, 'HIT@1': '0.1275', 'NDCG@1': '0.1275', 'HIT@5': '0.3541', 'NDCG@5': '0.2448', 'HIT@10': '0.4835', 'NDCG@10': '0.2868', 'MRR': '0.2456'} 166 | {'epoch': 82, 'rec_avg_loss': '0.5918', 'rec_cur_loss': '0.5705'} 167 | {'Epoch': 82, 'HIT@1': '0.1275', 'NDCG@1': '0.1275', 'HIT@5': '0.3569', 'NDCG@5': '0.2460', 'HIT@10': '0.4862', 'NDCG@10': '0.2879', 'MRR': '0.2461'} 168 | {'epoch': 83, 'rec_avg_loss': '0.5885', 'rec_cur_loss': '0.6001'} 169 | {'Epoch': 83, 'HIT@1': '0.1284', 'NDCG@1': '0.1284', 'HIT@5': '0.3569', 'NDCG@5': '0.2458', 'HIT@10': '0.4872', 'NDCG@10': '0.2879', 'MRR': '0.2458'} 170 | {'epoch': 84, 'rec_avg_loss': '0.5826', 'rec_cur_loss': '0.5655'} 171 | {'Epoch': 84, 'HIT@1': '0.1294', 'NDCG@1': '0.1294', 'HIT@5': '0.3615', 'NDCG@5': '0.2477', 'HIT@10': '0.4917', 'NDCG@10': '0.2899', 'MRR': '0.2468'} 172 | {'epoch': 85, 'rec_avg_loss': '0.5828', 'rec_cur_loss': '0.5706'} 173 | {'Epoch': 85, 'HIT@1': '0.1294', 'NDCG@1': '0.1294', 'HIT@5': '0.3725', 'NDCG@5': '0.2538', 'HIT@10': '0.4872', 'NDCG@10': '0.2908', 'MRR': '0.2495'} 174 | {'epoch': 86, 'rec_avg_loss': '0.5797', 'rec_cur_loss': '0.5799'} 175 | {'Epoch': 86, 'HIT@1': '0.1284', 'NDCG@1': '0.1284', 'HIT@5': '0.3716', 'NDCG@5': '0.2528', 'HIT@10': '0.4862', 'NDCG@10': '0.2899', 'MRR': '0.2486'} 176 | {'epoch': 87, 'rec_avg_loss': '0.5735', 'rec_cur_loss': '0.5666'} 177 | {'Epoch': 87, 'HIT@1': '0.1229', 'NDCG@1': '0.1229', 'HIT@5': '0.3670', 'NDCG@5': '0.2472', 'HIT@10': '0.4853', 'NDCG@10': '0.2854', 'MRR': '0.2431'} 178 | {'epoch': 88, 'rec_avg_loss': '0.5730', 'rec_cur_loss': '0.5852'} 179 | {'Epoch': 88, 'HIT@1': '0.1239', 'NDCG@1': '0.1239', 'HIT@5': '0.3642', 'NDCG@5': '0.2474', 'HIT@10': '0.4835', 'NDCG@10': '0.2864', 'MRR': '0.2450'} 180 | {'epoch': 89, 'rec_avg_loss': '0.5659', 'rec_cur_loss': '0.5783'} 181 | {'Epoch': 89, 'HIT@1': '0.1248', 'NDCG@1': '0.1248', 'HIT@5': '0.3670', 'NDCG@5': '0.2488', 'HIT@10': '0.4872', 'NDCG@10': '0.2877', 'MRR': '0.2456'} 182 | {'epoch': 90, 'rec_avg_loss': '0.5577', 'rec_cur_loss': '0.5638'} 183 | {'Epoch': 90, 'HIT@1': '0.1248', 'NDCG@1': '0.1248', 'HIT@5': '0.3633', 'NDCG@5': '0.2480', 'HIT@10': '0.4881', 'NDCG@10': '0.2885', 'MRR': '0.2462'} 184 | {'epoch': 91, 'rec_avg_loss': '0.5584', 'rec_cur_loss': '0.5496'} 185 | {'Epoch': 91, 'HIT@1': '0.1211', 'NDCG@1': '0.1211', 'HIT@5': '0.3633', 'NDCG@5': '0.2459', 'HIT@10': '0.4890', 'NDCG@10': '0.2867', 'MRR': '0.2437'} 186 | {'epoch': 92, 'rec_avg_loss': '0.5516', 'rec_cur_loss': '0.5630'} 187 | {'Epoch': 92, 'HIT@1': '0.1202', 'NDCG@1': '0.1202', 'HIT@5': '0.3670', 'NDCG@5': '0.2473', 'HIT@10': '0.4881', 'NDCG@10': '0.2866', 'MRR': '0.2439'} 188 | {'epoch': 93, 'rec_avg_loss': '0.5454', 'rec_cur_loss': '0.5207'} 189 | {'Epoch': 93, 'HIT@1': '0.1229', 'NDCG@1': '0.1229', 'HIT@5': '0.3624', 'NDCG@5': '0.2466', 'HIT@10': '0.4945', 'NDCG@10': '0.2897', 'MRR': '0.2457'} 190 | {'epoch': 94, 'rec_avg_loss': '0.5518', 'rec_cur_loss': '0.5776'} 191 | {'Epoch': 94, 'HIT@1': '0.1257', 'NDCG@1': '0.1257', 'HIT@5': '0.3725', 'NDCG@5': '0.2513', 'HIT@10': '0.4982', 'NDCG@10': '0.2920', 'MRR': '0.2475'} 192 | {'epoch': 95, 'rec_avg_loss': '0.5371', 'rec_cur_loss': '0.5291'} 193 | {'Epoch': 95, 'HIT@1': '0.1321', 'NDCG@1': '0.1321', 'HIT@5': '0.3743', 'NDCG@5': '0.2532', 'HIT@10': '0.5037', 'NDCG@10': '0.2949', 'MRR': '0.2495'} 194 | {'Epoch': 0, 'HIT@1': '0.1156', 'NDCG@1': '0.1156', 'HIT@5': '0.3092', 'NDCG@5': '0.2126', 'HIT@10': '0.4587', 'NDCG@10': '0.2605', 'MRR': '0.2209'} 195 | Finetune_sample-LastFM-0 196 | {'Epoch': 0, 'HIT@1': '0.1156', 'NDCG@1': '0.1156', 'HIT@5': '0.3092', 'NDCG@5': '0.2126', 'HIT@10': '0.4587', 'NDCG@10': '0.2605', 'MRR': '0.2209'} 197 | -------------------------------------------------------------------------------- /reproduce/Finetune_sample-LastFM-150.txt: -------------------------------------------------------------------------------- 1 | Namespace(adam_beta1=0.9, adam_beta2=0.999, attention_probs_dropout_prob=0.5, attribute_size=389, batch_size=256, ckp=150, cuda_condition=True, data_dir='../TOIS/data/', data_file='../TOIS/data/LastFM.txt', data_name='LastFM', do_eval=False, epochs=200, gpu_id='2', hidden_act='gelu', hidden_dropout_prob=0.5, hidden_size=64, initializer_range=0.02, item_size=3648, log_file='output/Finetune_sample-LastFM-150.txt', log_freq=1, lr=0.001, mask_id=3647, max_seq_length=50, model_name='Finetune_sample', no_cuda=False, num_attention_heads=2, num_hidden_layers=2, output_dir='output/', sample_file='../TOIS/data/LastFM_sample.txt', seed=42, weight_decay=0.0) 2 | {'epoch': 0, 'rec_avg_loss': '1.7752', 'rec_cur_loss': '1.6317'} 3 | {'Epoch': 0, 'HIT@1': '0.0633', 'NDCG@1': '0.0633', 'HIT@5': '0.2312', 'NDCG@5': '0.1492', 'HIT@10': '0.3550', 'NDCG@10': '0.1891', 'MRR': '0.1596'} 4 | {'epoch': 1, 'rec_avg_loss': '1.4744', 'rec_cur_loss': '1.3986'} 5 | {'Epoch': 1, 'HIT@1': '0.0807', 'NDCG@1': '0.0807', 'HIT@5': '0.2468', 'NDCG@5': '0.1659', 'HIT@10': '0.3890', 'NDCG@10': '0.2113', 'MRR': '0.1787'} 6 | {'epoch': 2, 'rec_avg_loss': '1.3062', 'rec_cur_loss': '1.2506'} 7 | {'Epoch': 2, 'HIT@1': '0.0927', 'NDCG@1': '0.0927', 'HIT@5': '0.2688', 'NDCG@5': '0.1807', 'HIT@10': '0.4092', 'NDCG@10': '0.2260', 'MRR': '0.1932'} 8 | {'epoch': 3, 'rec_avg_loss': '1.2506', 'rec_cur_loss': '1.3113'} 9 | {'Epoch': 3, 'HIT@1': '0.0954', 'NDCG@1': '0.0954', 'HIT@5': '0.3055', 'NDCG@5': '0.2020', 'HIT@10': '0.4532', 'NDCG@10': '0.2492', 'MRR': '0.2087'} 10 | {'epoch': 4, 'rec_avg_loss': '1.1843', 'rec_cur_loss': '1.1460'} 11 | {'Epoch': 4, 'HIT@1': '0.1073', 'NDCG@1': '0.1073', 'HIT@5': '0.3266', 'NDCG@5': '0.2180', 'HIT@10': '0.4853', 'NDCG@10': '0.2691', 'MRR': '0.2236'} 12 | {'epoch': 5, 'rec_avg_loss': '1.1555', 'rec_cur_loss': '1.1640'} 13 | {'Epoch': 5, 'HIT@1': '0.1064', 'NDCG@1': '0.1064', 'HIT@5': '0.3505', 'NDCG@5': '0.2297', 'HIT@10': '0.5138', 'NDCG@10': '0.2823', 'MRR': '0.2306'} 14 | {'epoch': 6, 'rec_avg_loss': '1.1072', 'rec_cur_loss': '1.0859'} 15 | {'Epoch': 6, 'HIT@1': '0.1138', 'NDCG@1': '0.1138', 'HIT@5': '0.3624', 'NDCG@5': '0.2408', 'HIT@10': '0.5193', 'NDCG@10': '0.2921', 'MRR': '0.2417'} 16 | {'epoch': 7, 'rec_avg_loss': '1.0796', 'rec_cur_loss': '1.0635'} 17 | {'Epoch': 7, 'HIT@1': '0.1138', 'NDCG@1': '0.1138', 'HIT@5': '0.3706', 'NDCG@5': '0.2485', 'HIT@10': '0.5330', 'NDCG@10': '0.3018', 'MRR': '0.2497'} 18 | {'epoch': 8, 'rec_avg_loss': '1.0314', 'rec_cur_loss': '1.0037'} 19 | {'Epoch': 8, 'HIT@1': '0.1211', 'NDCG@1': '0.1211', 'HIT@5': '0.3780', 'NDCG@5': '0.2542', 'HIT@10': '0.5440', 'NDCG@10': '0.3085', 'MRR': '0.2549'} 20 | {'epoch': 9, 'rec_avg_loss': '1.0138', 'rec_cur_loss': '0.9004'} 21 | {'Epoch': 9, 'HIT@1': '0.1294', 'NDCG@1': '0.1294', 'HIT@5': '0.3917', 'NDCG@5': '0.2647', 'HIT@10': '0.5523', 'NDCG@10': '0.3170', 'MRR': '0.2633'} 22 | {'epoch': 10, 'rec_avg_loss': '1.0159', 'rec_cur_loss': '1.0183'} 23 | {'Epoch': 10, 'HIT@1': '0.1239', 'NDCG@1': '0.1239', 'HIT@5': '0.4000', 'NDCG@5': '0.2671', 'HIT@10': '0.5587', 'NDCG@10': '0.3189', 'MRR': '0.2632'} 24 | {'epoch': 11, 'rec_avg_loss': '1.0012', 'rec_cur_loss': '0.9798'} 25 | {'Epoch': 11, 'HIT@1': '0.1266', 'NDCG@1': '0.1266', 'HIT@5': '0.4064', 'NDCG@5': '0.2710', 'HIT@10': '0.5596', 'NDCG@10': '0.3212', 'MRR': '0.2661'} 26 | {'epoch': 12, 'rec_avg_loss': '0.9780', 'rec_cur_loss': '0.9941'} 27 | {'Epoch': 12, 'HIT@1': '0.1294', 'NDCG@1': '0.1294', 'HIT@5': '0.4128', 'NDCG@5': '0.2749', 'HIT@10': '0.5679', 'NDCG@10': '0.3252', 'MRR': '0.2685'} 28 | {'epoch': 13, 'rec_avg_loss': '0.9582', 'rec_cur_loss': '0.9752'} 29 | {'Epoch': 13, 'HIT@1': '0.1330', 'NDCG@1': '0.1330', 'HIT@5': '0.4174', 'NDCG@5': '0.2793', 'HIT@10': '0.5679', 'NDCG@10': '0.3282', 'MRR': '0.2727'} 30 | {'epoch': 14, 'rec_avg_loss': '0.9397', 'rec_cur_loss': '0.9028'} 31 | {'Epoch': 14, 'HIT@1': '0.1404', 'NDCG@1': '0.1404', 'HIT@5': '0.4229', 'NDCG@5': '0.2859', 'HIT@10': '0.5752', 'NDCG@10': '0.3352', 'MRR': '0.2793'} 32 | {'epoch': 15, 'rec_avg_loss': '0.9310', 'rec_cur_loss': '0.9281'} 33 | {'Epoch': 15, 'HIT@1': '0.1358', 'NDCG@1': '0.1358', 'HIT@5': '0.4220', 'NDCG@5': '0.2836', 'HIT@10': '0.5734', 'NDCG@10': '0.3328', 'MRR': '0.2771'} 34 | {'epoch': 16, 'rec_avg_loss': '0.9078', 'rec_cur_loss': '0.8721'} 35 | {'Epoch': 16, 'HIT@1': '0.1431', 'NDCG@1': '0.1431', 'HIT@5': '0.4248', 'NDCG@5': '0.2882', 'HIT@10': '0.5716', 'NDCG@10': '0.3360', 'MRR': '0.2820'} 36 | {'epoch': 17, 'rec_avg_loss': '0.9110', 'rec_cur_loss': '0.9697'} 37 | {'Epoch': 17, 'HIT@1': '0.1422', 'NDCG@1': '0.1422', 'HIT@5': '0.4202', 'NDCG@5': '0.2872', 'HIT@10': '0.5807', 'NDCG@10': '0.3393', 'MRR': '0.2831'} 38 | {'epoch': 18, 'rec_avg_loss': '0.8929', 'rec_cur_loss': '0.9180'} 39 | {'Epoch': 18, 'HIT@1': '0.1486', 'NDCG@1': '0.1486', 'HIT@5': '0.4220', 'NDCG@5': '0.2907', 'HIT@10': '0.5826', 'NDCG@10': '0.3428', 'MRR': '0.2872'} 40 | {'epoch': 19, 'rec_avg_loss': '0.8794', 'rec_cur_loss': '0.8569'} 41 | {'Epoch': 19, 'HIT@1': '0.1550', 'NDCG@1': '0.1550', 'HIT@5': '0.4193', 'NDCG@5': '0.2933', 'HIT@10': '0.5862', 'NDCG@10': '0.3477', 'MRR': '0.2924'} 42 | {'epoch': 20, 'rec_avg_loss': '0.8816', 'rec_cur_loss': '0.8703'} 43 | {'Epoch': 20, 'HIT@1': '0.1514', 'NDCG@1': '0.1514', 'HIT@5': '0.4229', 'NDCG@5': '0.2947', 'HIT@10': '0.5835', 'NDCG@10': '0.3468', 'MRR': '0.2924'} 44 | {'epoch': 21, 'rec_avg_loss': '0.8607', 'rec_cur_loss': '0.8483'} 45 | {'Epoch': 21, 'HIT@1': '0.1523', 'NDCG@1': '0.1523', 'HIT@5': '0.4294', 'NDCG@5': '0.2975', 'HIT@10': '0.5835', 'NDCG@10': '0.3475', 'MRR': '0.2934'} 46 | {'epoch': 22, 'rec_avg_loss': '0.8424', 'rec_cur_loss': '0.8060'} 47 | {'Epoch': 22, 'HIT@1': '0.1514', 'NDCG@1': '0.1514', 'HIT@5': '0.4349', 'NDCG@5': '0.2990', 'HIT@10': '0.5899', 'NDCG@10': '0.3490', 'MRR': '0.2930'} 48 | {'epoch': 23, 'rec_avg_loss': '0.8523', 'rec_cur_loss': '0.9084'} 49 | {'Epoch': 23, 'HIT@1': '0.1495', 'NDCG@1': '0.1495', 'HIT@5': '0.4294', 'NDCG@5': '0.2958', 'HIT@10': '0.5844', 'NDCG@10': '0.3460', 'MRR': '0.2913'} 50 | {'epoch': 24, 'rec_avg_loss': '0.8242', 'rec_cur_loss': '0.7620'} 51 | {'Epoch': 24, 'HIT@1': '0.1440', 'NDCG@1': '0.1440', 'HIT@5': '0.4303', 'NDCG@5': '0.2943', 'HIT@10': '0.5862', 'NDCG@10': '0.3449', 'MRR': '0.2891'} 52 | {'epoch': 25, 'rec_avg_loss': '0.8255', 'rec_cur_loss': '0.8048'} 53 | {'Epoch': 25, 'HIT@1': '0.1440', 'NDCG@1': '0.1440', 'HIT@5': '0.4339', 'NDCG@5': '0.2964', 'HIT@10': '0.5890', 'NDCG@10': '0.3466', 'MRR': '0.2903'} 54 | {'epoch': 26, 'rec_avg_loss': '0.8163', 'rec_cur_loss': '0.8210'} 55 | {'Epoch': 26, 'HIT@1': '0.1514', 'NDCG@1': '0.1514', 'HIT@5': '0.4376', 'NDCG@5': '0.3009', 'HIT@10': '0.5954', 'NDCG@10': '0.3516', 'MRR': '0.2946'} 56 | {'epoch': 27, 'rec_avg_loss': '0.8111', 'rec_cur_loss': '0.8196'} 57 | {'Epoch': 27, 'HIT@1': '0.1495', 'NDCG@1': '0.1495', 'HIT@5': '0.4450', 'NDCG@5': '0.3027', 'HIT@10': '0.6018', 'NDCG@10': '0.3527', 'MRR': '0.2938'} 58 | {'epoch': 28, 'rec_avg_loss': '0.7996', 'rec_cur_loss': '0.7698'} 59 | {'Epoch': 28, 'HIT@1': '0.1550', 'NDCG@1': '0.1550', 'HIT@5': '0.4376', 'NDCG@5': '0.3034', 'HIT@10': '0.5991', 'NDCG@10': '0.3553', 'MRR': '0.2983'} 60 | {'epoch': 29, 'rec_avg_loss': '0.7919', 'rec_cur_loss': '0.8202'} 61 | {'Epoch': 29, 'HIT@1': '0.1596', 'NDCG@1': '0.1596', 'HIT@5': '0.4385', 'NDCG@5': '0.3055', 'HIT@10': '0.6046', 'NDCG@10': '0.3588', 'MRR': '0.3010'} 62 | {'epoch': 30, 'rec_avg_loss': '0.8029', 'rec_cur_loss': '0.8199'} 63 | {'Epoch': 30, 'HIT@1': '0.1578', 'NDCG@1': '0.1578', 'HIT@5': '0.4385', 'NDCG@5': '0.3043', 'HIT@10': '0.6028', 'NDCG@10': '0.3571', 'MRR': '0.2995'} 64 | {'epoch': 31, 'rec_avg_loss': '0.7968', 'rec_cur_loss': '0.8206'} 65 | {'Epoch': 31, 'HIT@1': '0.1532', 'NDCG@1': '0.1532', 'HIT@5': '0.4459', 'NDCG@5': '0.3062', 'HIT@10': '0.6028', 'NDCG@10': '0.3564', 'MRR': '0.2985'} 66 | {'epoch': 32, 'rec_avg_loss': '0.7832', 'rec_cur_loss': '0.7658'} 67 | {'Epoch': 32, 'HIT@1': '0.1541', 'NDCG@1': '0.1541', 'HIT@5': '0.4495', 'NDCG@5': '0.3081', 'HIT@10': '0.6018', 'NDCG@10': '0.3569', 'MRR': '0.2993'} 68 | {'epoch': 33, 'rec_avg_loss': '0.7773', 'rec_cur_loss': '0.7687'} 69 | {'Epoch': 33, 'HIT@1': '0.1569', 'NDCG@1': '0.1569', 'HIT@5': '0.4468', 'NDCG@5': '0.3087', 'HIT@10': '0.6073', 'NDCG@10': '0.3603', 'MRR': '0.3019'} 70 | {'epoch': 34, 'rec_avg_loss': '0.7720', 'rec_cur_loss': '0.7896'} 71 | {'Epoch': 34, 'HIT@1': '0.1550', 'NDCG@1': '0.1550', 'HIT@5': '0.4495', 'NDCG@5': '0.3074', 'HIT@10': '0.6055', 'NDCG@10': '0.3577', 'MRR': '0.2992'} 72 | {'epoch': 35, 'rec_avg_loss': '0.7675', 'rec_cur_loss': '0.7801'} 73 | {'Epoch': 35, 'HIT@1': '0.1578', 'NDCG@1': '0.1578', 'HIT@5': '0.4514', 'NDCG@5': '0.3090', 'HIT@10': '0.6055', 'NDCG@10': '0.3586', 'MRR': '0.3006'} 74 | {'epoch': 36, 'rec_avg_loss': '0.7556', 'rec_cur_loss': '0.7658'} 75 | {'Epoch': 36, 'HIT@1': '0.1532', 'NDCG@1': '0.1532', 'HIT@5': '0.4505', 'NDCG@5': '0.3084', 'HIT@10': '0.6028', 'NDCG@10': '0.3574', 'MRR': '0.3000'} 76 | {'epoch': 37, 'rec_avg_loss': '0.7582', 'rec_cur_loss': '0.7595'} 77 | {'Epoch': 37, 'HIT@1': '0.1587', 'NDCG@1': '0.1587', 'HIT@5': '0.4532', 'NDCG@5': '0.3122', 'HIT@10': '0.6055', 'NDCG@10': '0.3613', 'MRR': '0.3040'} 78 | {'epoch': 38, 'rec_avg_loss': '0.7537', 'rec_cur_loss': '0.7838'} 79 | {'Epoch': 38, 'HIT@1': '0.1587', 'NDCG@1': '0.1587', 'HIT@5': '0.4578', 'NDCG@5': '0.3148', 'HIT@10': '0.6028', 'NDCG@10': '0.3615', 'MRR': '0.3053'} 80 | {'epoch': 39, 'rec_avg_loss': '0.7494', 'rec_cur_loss': '0.7688'} 81 | {'Epoch': 39, 'HIT@1': '0.1606', 'NDCG@1': '0.1606', 'HIT@5': '0.4560', 'NDCG@5': '0.3137', 'HIT@10': '0.6037', 'NDCG@10': '0.3613', 'MRR': '0.3047'} 82 | {'epoch': 40, 'rec_avg_loss': '0.7464', 'rec_cur_loss': '0.7834'} 83 | {'Epoch': 40, 'HIT@1': '0.1596', 'NDCG@1': '0.1596', 'HIT@5': '0.4587', 'NDCG@5': '0.3148', 'HIT@10': '0.6037', 'NDCG@10': '0.3618', 'MRR': '0.3051'} 84 | {'epoch': 41, 'rec_avg_loss': '0.7351', 'rec_cur_loss': '0.7492'} 85 | {'Epoch': 41, 'HIT@1': '0.1624', 'NDCG@1': '0.1624', 'HIT@5': '0.4615', 'NDCG@5': '0.3165', 'HIT@10': '0.6028', 'NDCG@10': '0.3624', 'MRR': '0.3064'} 86 | {'epoch': 42, 'rec_avg_loss': '0.7358', 'rec_cur_loss': '0.7621'} 87 | {'Epoch': 42, 'HIT@1': '0.1642', 'NDCG@1': '0.1642', 'HIT@5': '0.4642', 'NDCG@5': '0.3181', 'HIT@10': '0.6018', 'NDCG@10': '0.3623', 'MRR': '0.3067'} 88 | {'epoch': 43, 'rec_avg_loss': '0.7273', 'rec_cur_loss': '0.7221'} 89 | {'Epoch': 43, 'HIT@1': '0.1633', 'NDCG@1': '0.1633', 'HIT@5': '0.4569', 'NDCG@5': '0.3163', 'HIT@10': '0.6028', 'NDCG@10': '0.3633', 'MRR': '0.3077'} 90 | {'epoch': 44, 'rec_avg_loss': '0.7351', 'rec_cur_loss': '0.7469'} 91 | {'Epoch': 44, 'HIT@1': '0.1606', 'NDCG@1': '0.1606', 'HIT@5': '0.4578', 'NDCG@5': '0.3164', 'HIT@10': '0.6046', 'NDCG@10': '0.3634', 'MRR': '0.3072'} 92 | {'epoch': 45, 'rec_avg_loss': '0.7170', 'rec_cur_loss': '0.7054'} 93 | {'Epoch': 45, 'HIT@1': '0.1615', 'NDCG@1': '0.1615', 'HIT@5': '0.4560', 'NDCG@5': '0.3155', 'HIT@10': '0.6092', 'NDCG@10': '0.3645', 'MRR': '0.3070'} 94 | {'epoch': 46, 'rec_avg_loss': '0.7122', 'rec_cur_loss': '0.7292'} 95 | {'Epoch': 46, 'HIT@1': '0.1615', 'NDCG@1': '0.1615', 'HIT@5': '0.4532', 'NDCG@5': '0.3149', 'HIT@10': '0.6055', 'NDCG@10': '0.3639', 'MRR': '0.3076'} 96 | {'epoch': 47, 'rec_avg_loss': '0.7036', 'rec_cur_loss': '0.6398'} 97 | {'Epoch': 47, 'HIT@1': '0.1642', 'NDCG@1': '0.1642', 'HIT@5': '0.4596', 'NDCG@5': '0.3192', 'HIT@10': '0.6037', 'NDCG@10': '0.3652', 'MRR': '0.3100'} 98 | {'epoch': 48, 'rec_avg_loss': '0.6985', 'rec_cur_loss': '0.6772'} 99 | {'Epoch': 48, 'HIT@1': '0.1670', 'NDCG@1': '0.1670', 'HIT@5': '0.4578', 'NDCG@5': '0.3197', 'HIT@10': '0.6055', 'NDCG@10': '0.3672', 'MRR': '0.3119'} 100 | {'epoch': 49, 'rec_avg_loss': '0.7068', 'rec_cur_loss': '0.6874'} 101 | {'Epoch': 49, 'HIT@1': '0.1633', 'NDCG@1': '0.1633', 'HIT@5': '0.4578', 'NDCG@5': '0.3180', 'HIT@10': '0.6128', 'NDCG@10': '0.3677', 'MRR': '0.3098'} 102 | {'epoch': 50, 'rec_avg_loss': '0.6995', 'rec_cur_loss': '0.7031'} 103 | {'Epoch': 50, 'HIT@1': '0.1651', 'NDCG@1': '0.1651', 'HIT@5': '0.4606', 'NDCG@5': '0.3201', 'HIT@10': '0.6092', 'NDCG@10': '0.3678', 'MRR': '0.3113'} 104 | {'epoch': 51, 'rec_avg_loss': '0.7006', 'rec_cur_loss': '0.7221'} 105 | {'Epoch': 51, 'HIT@1': '0.1633', 'NDCG@1': '0.1633', 'HIT@5': '0.4560', 'NDCG@5': '0.3180', 'HIT@10': '0.6101', 'NDCG@10': '0.3674', 'MRR': '0.3104'} 106 | {'epoch': 52, 'rec_avg_loss': '0.6968', 'rec_cur_loss': '0.6879'} 107 | {'Epoch': 52, 'HIT@1': '0.1596', 'NDCG@1': '0.1596', 'HIT@5': '0.4578', 'NDCG@5': '0.3173', 'HIT@10': '0.6092', 'NDCG@10': '0.3658', 'MRR': '0.3084'} 108 | {'epoch': 53, 'rec_avg_loss': '0.7031', 'rec_cur_loss': '0.7096'} 109 | {'Epoch': 53, 'HIT@1': '0.1651', 'NDCG@1': '0.1651', 'HIT@5': '0.4569', 'NDCG@5': '0.3175', 'HIT@10': '0.5982', 'NDCG@10': '0.3630', 'MRR': '0.3090'} 110 | {'epoch': 54, 'rec_avg_loss': '0.6841', 'rec_cur_loss': '0.6638'} 111 | {'Epoch': 54, 'HIT@1': '0.1661', 'NDCG@1': '0.1661', 'HIT@5': '0.4514', 'NDCG@5': '0.3151', 'HIT@10': '0.5972', 'NDCG@10': '0.3623', 'MRR': '0.3085'} 112 | {'epoch': 55, 'rec_avg_loss': '0.6812', 'rec_cur_loss': '0.6675'} 113 | {'Epoch': 55, 'HIT@1': '0.1642', 'NDCG@1': '0.1642', 'HIT@5': '0.4523', 'NDCG@5': '0.3149', 'HIT@10': '0.5991', 'NDCG@10': '0.3621', 'MRR': '0.3077'} 114 | {'epoch': 56, 'rec_avg_loss': '0.6767', 'rec_cur_loss': '0.6334'} 115 | {'Epoch': 56, 'HIT@1': '0.1624', 'NDCG@1': '0.1624', 'HIT@5': '0.4532', 'NDCG@5': '0.3159', 'HIT@10': '0.6055', 'NDCG@10': '0.3648', 'MRR': '0.3089'} 116 | {'epoch': 57, 'rec_avg_loss': '0.6790', 'rec_cur_loss': '0.6900'} 117 | {'Epoch': 57, 'HIT@1': '0.1633', 'NDCG@1': '0.1633', 'HIT@5': '0.4523', 'NDCG@5': '0.3156', 'HIT@10': '0.6055', 'NDCG@10': '0.3651', 'MRR': '0.3093'} 118 | {'epoch': 58, 'rec_avg_loss': '0.6717', 'rec_cur_loss': '0.6689'} 119 | {'Epoch': 58, 'HIT@1': '0.1688', 'NDCG@1': '0.1688', 'HIT@5': '0.4569', 'NDCG@5': '0.3192', 'HIT@10': '0.6083', 'NDCG@10': '0.3679', 'MRR': '0.3120'} 120 | {'epoch': 59, 'rec_avg_loss': '0.6706', 'rec_cur_loss': '0.6498'} 121 | {'Epoch': 59, 'HIT@1': '0.1706', 'NDCG@1': '0.1706', 'HIT@5': '0.4541', 'NDCG@5': '0.3192', 'HIT@10': '0.6073', 'NDCG@10': '0.3685', 'MRR': '0.3134'} 122 | {'epoch': 60, 'rec_avg_loss': '0.6717', 'rec_cur_loss': '0.6635'} 123 | {'Epoch': 60, 'HIT@1': '0.1679', 'NDCG@1': '0.1679', 'HIT@5': '0.4541', 'NDCG@5': '0.3182', 'HIT@10': '0.6046', 'NDCG@10': '0.3671', 'MRR': '0.3122'} 124 | {'epoch': 61, 'rec_avg_loss': '0.6676', 'rec_cur_loss': '0.6625'} 125 | {'Epoch': 61, 'HIT@1': '0.1670', 'NDCG@1': '0.1670', 'HIT@5': '0.4578', 'NDCG@5': '0.3198', 'HIT@10': '0.6083', 'NDCG@10': '0.3683', 'MRR': '0.3123'} 126 | {'epoch': 62, 'rec_avg_loss': '0.6653', 'rec_cur_loss': '0.6796'} 127 | {'Epoch': 62, 'HIT@1': '0.1642', 'NDCG@1': '0.1642', 'HIT@5': '0.4550', 'NDCG@5': '0.3182', 'HIT@10': '0.6092', 'NDCG@10': '0.3679', 'MRR': '0.3113'} 128 | {'epoch': 63, 'rec_avg_loss': '0.6636', 'rec_cur_loss': '0.6998'} 129 | {'Epoch': 63, 'HIT@1': '0.1651', 'NDCG@1': '0.1651', 'HIT@5': '0.4569', 'NDCG@5': '0.3193', 'HIT@10': '0.6101', 'NDCG@10': '0.3686', 'MRR': '0.3118'} 130 | {'epoch': 64, 'rec_avg_loss': '0.6716', 'rec_cur_loss': '0.7125'} 131 | {'Epoch': 64, 'HIT@1': '0.1642', 'NDCG@1': '0.1642', 'HIT@5': '0.4569', 'NDCG@5': '0.3197', 'HIT@10': '0.6046', 'NDCG@10': '0.3674', 'MRR': '0.3122'} 132 | {'epoch': 65, 'rec_avg_loss': '0.6412', 'rec_cur_loss': '0.6125'} 133 | {'Epoch': 65, 'HIT@1': '0.1688', 'NDCG@1': '0.1688', 'HIT@5': '0.4624', 'NDCG@5': '0.3233', 'HIT@10': '0.6028', 'NDCG@10': '0.3685', 'MRR': '0.3146'} 134 | {'epoch': 66, 'rec_avg_loss': '0.6462', 'rec_cur_loss': '0.6738'} 135 | {'Epoch': 66, 'HIT@1': '0.1670', 'NDCG@1': '0.1670', 'HIT@5': '0.4596', 'NDCG@5': '0.3213', 'HIT@10': '0.6037', 'NDCG@10': '0.3679', 'MRR': '0.3133'} 136 | {'epoch': 67, 'rec_avg_loss': '0.6547', 'rec_cur_loss': '0.6726'} 137 | {'Epoch': 67, 'HIT@1': '0.1706', 'NDCG@1': '0.1706', 'HIT@5': '0.4606', 'NDCG@5': '0.3233', 'HIT@10': '0.6055', 'NDCG@10': '0.3701', 'MRR': '0.3154'} 138 | {'epoch': 68, 'rec_avg_loss': '0.6503', 'rec_cur_loss': '0.6530'} 139 | {'Epoch': 68, 'HIT@1': '0.1725', 'NDCG@1': '0.1725', 'HIT@5': '0.4606', 'NDCG@5': '0.3246', 'HIT@10': '0.6037', 'NDCG@10': '0.3709', 'MRR': '0.3172'} 140 | {'epoch': 69, 'rec_avg_loss': '0.6462', 'rec_cur_loss': '0.6492'} 141 | {'Epoch': 69, 'HIT@1': '0.1734', 'NDCG@1': '0.1734', 'HIT@5': '0.4633', 'NDCG@5': '0.3255', 'HIT@10': '0.6009', 'NDCG@10': '0.3699', 'MRR': '0.3168'} 142 | {'epoch': 70, 'rec_avg_loss': '0.6423', 'rec_cur_loss': '0.6474'} 143 | {'Epoch': 70, 'HIT@1': '0.1679', 'NDCG@1': '0.1679', 'HIT@5': '0.4633', 'NDCG@5': '0.3242', 'HIT@10': '0.6028', 'NDCG@10': '0.3691', 'MRR': '0.3151'} 144 | {'epoch': 71, 'rec_avg_loss': '0.6398', 'rec_cur_loss': '0.6351'} 145 | {'Epoch': 71, 'HIT@1': '0.1679', 'NDCG@1': '0.1679', 'HIT@5': '0.4642', 'NDCG@5': '0.3249', 'HIT@10': '0.6073', 'NDCG@10': '0.3708', 'MRR': '0.3157'} 146 | {'epoch': 72, 'rec_avg_loss': '0.6290', 'rec_cur_loss': '0.5937'} 147 | {'Epoch': 72, 'HIT@1': '0.1651', 'NDCG@1': '0.1651', 'HIT@5': '0.4651', 'NDCG@5': '0.3238', 'HIT@10': '0.6101', 'NDCG@10': '0.3704', 'MRR': '0.3139'} 148 | {'epoch': 73, 'rec_avg_loss': '0.6403', 'rec_cur_loss': '0.6439'} 149 | {'Epoch': 73, 'HIT@1': '0.1633', 'NDCG@1': '0.1633', 'HIT@5': '0.4587', 'NDCG@5': '0.3211', 'HIT@10': '0.6101', 'NDCG@10': '0.3701', 'MRR': '0.3134'} 150 | {'epoch': 74, 'rec_avg_loss': '0.6330', 'rec_cur_loss': '0.6395'} 151 | {'Epoch': 74, 'HIT@1': '0.1706', 'NDCG@1': '0.1706', 'HIT@5': '0.4651', 'NDCG@5': '0.3247', 'HIT@10': '0.6064', 'NDCG@10': '0.3699', 'MRR': '0.3150'} 152 | {'epoch': 75, 'rec_avg_loss': '0.6372', 'rec_cur_loss': '0.6546'} 153 | {'Epoch': 75, 'HIT@1': '0.1725', 'NDCG@1': '0.1725', 'HIT@5': '0.4661', 'NDCG@5': '0.3257', 'HIT@10': '0.6064', 'NDCG@10': '0.3706', 'MRR': '0.3159'} 154 | {'epoch': 76, 'rec_avg_loss': '0.6230', 'rec_cur_loss': '0.6085'} 155 | {'Epoch': 76, 'HIT@1': '0.1697', 'NDCG@1': '0.1697', 'HIT@5': '0.4578', 'NDCG@5': '0.3218', 'HIT@10': '0.6037', 'NDCG@10': '0.3691', 'MRR': '0.3150'} 156 | {'epoch': 77, 'rec_avg_loss': '0.6256', 'rec_cur_loss': '0.6340'} 157 | {'Epoch': 77, 'HIT@1': '0.1679', 'NDCG@1': '0.1679', 'HIT@5': '0.4569', 'NDCG@5': '0.3208', 'HIT@10': '0.6037', 'NDCG@10': '0.3683', 'MRR': '0.3138'} 158 | {'epoch': 78, 'rec_avg_loss': '0.6244', 'rec_cur_loss': '0.6328'} 159 | {'Epoch': 78, 'HIT@1': '0.1688', 'NDCG@1': '0.1688', 'HIT@5': '0.4587', 'NDCG@5': '0.3225', 'HIT@10': '0.6028', 'NDCG@10': '0.3690', 'MRR': '0.3151'} 160 | {'Epoch': 0, 'HIT@1': '0.1569', 'NDCG@1': '0.1569', 'HIT@5': '0.4477', 'NDCG@5': '0.3056', 'HIT@10': '0.6083', 'NDCG@10': '0.3577', 'MRR': '0.2981'} 161 | Finetune_sample-LastFM-150 162 | {'Epoch': 0, 'HIT@1': '0.1569', 'NDCG@1': '0.1569', 'HIT@5': '0.4477', 'NDCG@5': '0.3056', 'HIT@10': '0.6083', 'NDCG@10': '0.3577', 'MRR': '0.2981'} 163 | -------------------------------------------------------------------------------- /reproduce/Finetune_sample-Sports_and_Outdoors-0.txt: -------------------------------------------------------------------------------- 1 | Namespace(adam_beta1=0.9, adam_beta2=0.999, attention_probs_dropout_prob=0.5, attribute_size=2278, batch_size=256, ckp=0, cuda_condition=True, data_dir='../TOIS/data/', data_file='../TOIS/data/Sports_and_Outdoors.txt', data_name='Sports_and_Outdoors', do_eval=False, epochs=200, gpu_id='0', hidden_act='gelu', hidden_dropout_prob=0.5, hidden_size=64, initializer_range=0.02, item_size=18359, log_file='output/Finetune_sample-Sports_and_Outdoors-0.txt', log_freq=1, lr=0.001, mask_id=18358, max_seq_length=50, model_name='Finetune_sample', no_cuda=False, num_attention_heads=2, num_hidden_layers=2, output_dir='output/', sample_file='../TOIS/data/Sports_and_Outdoors_sample.txt', seed=42, weight_decay=0.0) 2 | {'epoch': 0, 'rec_avg_loss': '1.3009', 'rec_cur_loss': '1.1716'} 3 | {'Epoch': 0, 'HIT@1': '0.0848', 'NDCG@1': '0.0848', 'HIT@5': '0.2457', 'NDCG@5': '0.1664', 'HIT@10': '0.3561', 'NDCG@10': '0.2019', 'MRR': '0.1753'} 4 | {'epoch': 1, 'rec_avg_loss': '1.1855', 'rec_cur_loss': '1.2658'} 5 | {'Epoch': 1, 'HIT@1': '0.0859', 'NDCG@1': '0.0859', 'HIT@5': '0.2496', 'NDCG@5': '0.1690', 'HIT@10': '0.3633', 'NDCG@10': '0.2056', 'MRR': '0.1780'} 6 | {'epoch': 2, 'rec_avg_loss': '1.1439', 'rec_cur_loss': '1.2257'} 7 | {'Epoch': 2, 'HIT@1': '0.0892', 'NDCG@1': '0.0892', 'HIT@5': '0.2548', 'NDCG@5': '0.1733', 'HIT@10': '0.3725', 'NDCG@10': '0.2113', 'MRR': '0.1824'} 8 | {'epoch': 3, 'rec_avg_loss': '1.0929', 'rec_cur_loss': '1.1121'} 9 | {'Epoch': 3, 'HIT@1': '0.1067', 'NDCG@1': '0.1067', 'HIT@5': '0.2871', 'NDCG@5': '0.1991', 'HIT@10': '0.4009', 'NDCG@10': '0.2358', 'MRR': '0.2050'} 10 | {'epoch': 4, 'rec_avg_loss': '1.0203', 'rec_cur_loss': '1.0212'} 11 | {'Epoch': 4, 'HIT@1': '0.1266', 'NDCG@1': '0.1266', 'HIT@5': '0.3221', 'NDCG@5': '0.2271', 'HIT@10': '0.4383', 'NDCG@10': '0.2646', 'MRR': '0.2307'} 12 | {'epoch': 5, 'rec_avg_loss': '0.9500', 'rec_cur_loss': '0.9662'} 13 | {'Epoch': 5, 'HIT@1': '0.1383', 'NDCG@1': '0.1383', 'HIT@5': '0.3363', 'NDCG@5': '0.2405', 'HIT@10': '0.4555', 'NDCG@10': '0.2789', 'MRR': '0.2439'} 14 | {'epoch': 6, 'rec_avg_loss': '0.8957', 'rec_cur_loss': '0.8013'} 15 | {'Epoch': 6, 'HIT@1': '0.1440', 'NDCG@1': '0.1440', 'HIT@5': '0.3500', 'NDCG@5': '0.2503', 'HIT@10': '0.4708', 'NDCG@10': '0.2893', 'MRR': '0.2528'} 16 | {'epoch': 7, 'rec_avg_loss': '0.8465', 'rec_cur_loss': '0.7809'} 17 | {'Epoch': 7, 'HIT@1': '0.1527', 'NDCG@1': '0.1527', 'HIT@5': '0.3580', 'NDCG@5': '0.2586', 'HIT@10': '0.4797', 'NDCG@10': '0.2978', 'MRR': '0.2610'} 18 | {'epoch': 8, 'rec_avg_loss': '0.8038', 'rec_cur_loss': '0.8462'} 19 | {'Epoch': 8, 'HIT@1': '0.1557', 'NDCG@1': '0.1557', 'HIT@5': '0.3658', 'NDCG@5': '0.2638', 'HIT@10': '0.4860', 'NDCG@10': '0.3026', 'MRR': '0.2651'} 20 | {'epoch': 9, 'rec_avg_loss': '0.7647', 'rec_cur_loss': '0.7708'} 21 | {'Epoch': 9, 'HIT@1': '0.1594', 'NDCG@1': '0.1594', 'HIT@5': '0.3698', 'NDCG@5': '0.2681', 'HIT@10': '0.4929', 'NDCG@10': '0.3077', 'MRR': '0.2697'} 22 | {'epoch': 10, 'rec_avg_loss': '0.7332', 'rec_cur_loss': '0.5725'} 23 | {'Epoch': 10, 'HIT@1': '0.1610', 'NDCG@1': '0.1610', 'HIT@5': '0.3754', 'NDCG@5': '0.2716', 'HIT@10': '0.5010', 'NDCG@10': '0.3121', 'MRR': '0.2726'} 24 | {'epoch': 11, 'rec_avg_loss': '0.7017', 'rec_cur_loss': '0.8606'} 25 | {'Epoch': 11, 'HIT@1': '0.1641', 'NDCG@1': '0.1641', 'HIT@5': '0.3788', 'NDCG@5': '0.2748', 'HIT@10': '0.4993', 'NDCG@10': '0.3137', 'MRR': '0.2755'} 26 | {'epoch': 12, 'rec_avg_loss': '0.6792', 'rec_cur_loss': '0.7462'} 27 | {'Epoch': 12, 'HIT@1': '0.1659', 'NDCG@1': '0.1659', 'HIT@5': '0.3849', 'NDCG@5': '0.2788', 'HIT@10': '0.5071', 'NDCG@10': '0.3182', 'MRR': '0.2785'} 28 | {'epoch': 13, 'rec_avg_loss': '0.6574', 'rec_cur_loss': '0.8288'} 29 | {'Epoch': 13, 'HIT@1': '0.1666', 'NDCG@1': '0.1666', 'HIT@5': '0.3825', 'NDCG@5': '0.2779', 'HIT@10': '0.5056', 'NDCG@10': '0.3176', 'MRR': '0.2783'} 30 | {'epoch': 14, 'rec_avg_loss': '0.6364', 'rec_cur_loss': '0.7311'} 31 | {'Epoch': 14, 'HIT@1': '0.1677', 'NDCG@1': '0.1677', 'HIT@5': '0.3849', 'NDCG@5': '0.2798', 'HIT@10': '0.5074', 'NDCG@10': '0.3194', 'MRR': '0.2801'} 32 | {'epoch': 15, 'rec_avg_loss': '0.6199', 'rec_cur_loss': '0.5066'} 33 | {'Epoch': 15, 'HIT@1': '0.1694', 'NDCG@1': '0.1694', 'HIT@5': '0.3861', 'NDCG@5': '0.2813', 'HIT@10': '0.5089', 'NDCG@10': '0.3209', 'MRR': '0.2815'} 34 | {'epoch': 16, 'rec_avg_loss': '0.6030', 'rec_cur_loss': '0.5576'} 35 | {'Epoch': 16, 'HIT@1': '0.1691', 'NDCG@1': '0.1691', 'HIT@5': '0.3874', 'NDCG@5': '0.2817', 'HIT@10': '0.5097', 'NDCG@10': '0.3211', 'MRR': '0.2816'} 36 | {'epoch': 17, 'rec_avg_loss': '0.5927', 'rec_cur_loss': '0.6257'} 37 | {'Epoch': 17, 'HIT@1': '0.1697', 'NDCG@1': '0.1697', 'HIT@5': '0.3880', 'NDCG@5': '0.2825', 'HIT@10': '0.5115', 'NDCG@10': '0.3224', 'MRR': '0.2826'} 38 | {'epoch': 18, 'rec_avg_loss': '0.5801', 'rec_cur_loss': '0.7595'} 39 | {'Epoch': 18, 'HIT@1': '0.1714', 'NDCG@1': '0.1714', 'HIT@5': '0.3883', 'NDCG@5': '0.2837', 'HIT@10': '0.5101', 'NDCG@10': '0.3230', 'MRR': '0.2839'} 40 | {'epoch': 19, 'rec_avg_loss': '0.5699', 'rec_cur_loss': '0.6314'} 41 | {'Epoch': 19, 'HIT@1': '0.1710', 'NDCG@1': '0.1710', 'HIT@5': '0.3892', 'NDCG@5': '0.2838', 'HIT@10': '0.5102', 'NDCG@10': '0.3228', 'MRR': '0.2837'} 42 | {'epoch': 20, 'rec_avg_loss': '0.5560', 'rec_cur_loss': '0.5283'} 43 | {'Epoch': 20, 'HIT@1': '0.1705', 'NDCG@1': '0.1705', 'HIT@5': '0.3872', 'NDCG@5': '0.2825', 'HIT@10': '0.5064', 'NDCG@10': '0.3210', 'MRR': '0.2826'} 44 | {'epoch': 21, 'rec_avg_loss': '0.5501', 'rec_cur_loss': '0.6971'} 45 | {'Epoch': 21, 'HIT@1': '0.1726', 'NDCG@1': '0.1726', 'HIT@5': '0.3889', 'NDCG@5': '0.2842', 'HIT@10': '0.5122', 'NDCG@10': '0.3240', 'MRR': '0.2846'} 46 | {'epoch': 22, 'rec_avg_loss': '0.5456', 'rec_cur_loss': '0.6469'} 47 | {'Epoch': 22, 'HIT@1': '0.1712', 'NDCG@1': '0.1712', 'HIT@5': '0.3880', 'NDCG@5': '0.2835', 'HIT@10': '0.5107', 'NDCG@10': '0.3231', 'MRR': '0.2839'} 48 | {'epoch': 23, 'rec_avg_loss': '0.5383', 'rec_cur_loss': '0.5032'} 49 | {'Epoch': 23, 'HIT@1': '0.1734', 'NDCG@1': '0.1734', 'HIT@5': '0.3894', 'NDCG@5': '0.2849', 'HIT@10': '0.5137', 'NDCG@10': '0.3250', 'MRR': '0.2855'} 50 | {'epoch': 24, 'rec_avg_loss': '0.5300', 'rec_cur_loss': '0.4786'} 51 | {'Epoch': 24, 'HIT@1': '0.1705', 'NDCG@1': '0.1705', 'HIT@5': '0.3879', 'NDCG@5': '0.2830', 'HIT@10': '0.5121', 'NDCG@10': '0.3230', 'MRR': '0.2833'} 52 | {'epoch': 25, 'rec_avg_loss': '0.5214', 'rec_cur_loss': '0.4994'} 53 | {'Epoch': 25, 'HIT@1': '0.1722', 'NDCG@1': '0.1722', 'HIT@5': '0.3892', 'NDCG@5': '0.2844', 'HIT@10': '0.5133', 'NDCG@10': '0.3245', 'MRR': '0.2848'} 54 | {'epoch': 26, 'rec_avg_loss': '0.5211', 'rec_cur_loss': '0.5854'} 55 | {'Epoch': 26, 'HIT@1': '0.1714', 'NDCG@1': '0.1714', 'HIT@5': '0.3879', 'NDCG@5': '0.2835', 'HIT@10': '0.5113', 'NDCG@10': '0.3233', 'MRR': '0.2839'} 56 | {'epoch': 27, 'rec_avg_loss': '0.5077', 'rec_cur_loss': '0.5176'} 57 | {'Epoch': 27, 'HIT@1': '0.1690', 'NDCG@1': '0.1690', 'HIT@5': '0.3884', 'NDCG@5': '0.2827', 'HIT@10': '0.5127', 'NDCG@10': '0.3227', 'MRR': '0.2827'} 58 | {'epoch': 28, 'rec_avg_loss': '0.5090', 'rec_cur_loss': '0.6720'} 59 | {'Epoch': 28, 'HIT@1': '0.1726', 'NDCG@1': '0.1726', 'HIT@5': '0.3902', 'NDCG@5': '0.2852', 'HIT@10': '0.5151', 'NDCG@10': '0.3254', 'MRR': '0.2854'} 60 | {'epoch': 29, 'rec_avg_loss': '0.5050', 'rec_cur_loss': '0.4414'} 61 | {'Epoch': 29, 'HIT@1': '0.1725', 'NDCG@1': '0.1725', 'HIT@5': '0.3886', 'NDCG@5': '0.2847', 'HIT@10': '0.5154', 'NDCG@10': '0.3255', 'MRR': '0.2855'} 62 | {'epoch': 30, 'rec_avg_loss': '0.4972', 'rec_cur_loss': '0.5820'} 63 | {'Epoch': 30, 'HIT@1': '0.1714', 'NDCG@1': '0.1714', 'HIT@5': '0.3900', 'NDCG@5': '0.2844', 'HIT@10': '0.5147', 'NDCG@10': '0.3245', 'MRR': '0.2844'} 64 | {'epoch': 31, 'rec_avg_loss': '0.4931', 'rec_cur_loss': '0.4268'} 65 | {'Epoch': 31, 'HIT@1': '0.1716', 'NDCG@1': '0.1716', 'HIT@5': '0.3924', 'NDCG@5': '0.2857', 'HIT@10': '0.5185', 'NDCG@10': '0.3263', 'MRR': '0.2854'} 66 | {'epoch': 32, 'rec_avg_loss': '0.4897', 'rec_cur_loss': '0.6136'} 67 | {'Epoch': 32, 'HIT@1': '0.1740', 'NDCG@1': '0.1740', 'HIT@5': '0.3909', 'NDCG@5': '0.2860', 'HIT@10': '0.5158', 'NDCG@10': '0.3263', 'MRR': '0.2863'} 68 | {'epoch': 33, 'rec_avg_loss': '0.4880', 'rec_cur_loss': '0.3301'} 69 | {'Epoch': 33, 'HIT@1': '0.1747', 'NDCG@1': '0.1747', 'HIT@5': '0.3916', 'NDCG@5': '0.2866', 'HIT@10': '0.5158', 'NDCG@10': '0.3267', 'MRR': '0.2869'} 70 | {'epoch': 34, 'rec_avg_loss': '0.4832', 'rec_cur_loss': '0.5354'} 71 | {'Epoch': 34, 'HIT@1': '0.1742', 'NDCG@1': '0.1742', 'HIT@5': '0.3906', 'NDCG@5': '0.2858', 'HIT@10': '0.5151', 'NDCG@10': '0.3261', 'MRR': '0.2863'} 72 | {'epoch': 35, 'rec_avg_loss': '0.4822', 'rec_cur_loss': '0.4940'} 73 | {'Epoch': 35, 'HIT@1': '0.1739', 'NDCG@1': '0.1739', 'HIT@5': '0.3914', 'NDCG@5': '0.2861', 'HIT@10': '0.5132', 'NDCG@10': '0.3254', 'MRR': '0.2861'} 74 | {'epoch': 36, 'rec_avg_loss': '0.4750', 'rec_cur_loss': '0.5491'} 75 | {'Epoch': 36, 'HIT@1': '0.1755', 'NDCG@1': '0.1755', 'HIT@5': '0.3922', 'NDCG@5': '0.2876', 'HIT@10': '0.5168', 'NDCG@10': '0.3278', 'MRR': '0.2880'} 76 | {'epoch': 37, 'rec_avg_loss': '0.4779', 'rec_cur_loss': '0.6213'} 77 | {'Epoch': 37, 'HIT@1': '0.1772', 'NDCG@1': '0.1772', 'HIT@5': '0.3931', 'NDCG@5': '0.2888', 'HIT@10': '0.5180', 'NDCG@10': '0.3291', 'MRR': '0.2894'} 78 | {'epoch': 38, 'rec_avg_loss': '0.4730', 'rec_cur_loss': '0.4776'} 79 | {'Epoch': 38, 'HIT@1': '0.1773', 'NDCG@1': '0.1773', 'HIT@5': '0.3930', 'NDCG@5': '0.2888', 'HIT@10': '0.5199', 'NDCG@10': '0.3297', 'MRR': '0.2895'} 80 | {'epoch': 39, 'rec_avg_loss': '0.4719', 'rec_cur_loss': '0.4589'} 81 | {'Epoch': 39, 'HIT@1': '0.1753', 'NDCG@1': '0.1753', 'HIT@5': '0.3914', 'NDCG@5': '0.2868', 'HIT@10': '0.5175', 'NDCG@10': '0.3275', 'MRR': '0.2874'} 82 | {'epoch': 40, 'rec_avg_loss': '0.4684', 'rec_cur_loss': '0.4383'} 83 | {'Epoch': 40, 'HIT@1': '0.1754', 'NDCG@1': '0.1754', 'HIT@5': '0.3922', 'NDCG@5': '0.2870', 'HIT@10': '0.5174', 'NDCG@10': '0.3274', 'MRR': '0.2872'} 84 | {'epoch': 41, 'rec_avg_loss': '0.4630', 'rec_cur_loss': '0.5735'} 85 | {'Epoch': 41, 'HIT@1': '0.1736', 'NDCG@1': '0.1736', 'HIT@5': '0.3910', 'NDCG@5': '0.2860', 'HIT@10': '0.5167', 'NDCG@10': '0.3266', 'MRR': '0.2863'} 86 | {'epoch': 42, 'rec_avg_loss': '0.4650', 'rec_cur_loss': '0.6112'} 87 | {'Epoch': 42, 'HIT@1': '0.1748', 'NDCG@1': '0.1748', 'HIT@5': '0.3929', 'NDCG@5': '0.2874', 'HIT@10': '0.5187', 'NDCG@10': '0.3280', 'MRR': '0.2875'} 88 | {'epoch': 43, 'rec_avg_loss': '0.4640', 'rec_cur_loss': '0.5279'} 89 | {'Epoch': 43, 'HIT@1': '0.1769', 'NDCG@1': '0.1769', 'HIT@5': '0.3949', 'NDCG@5': '0.2896', 'HIT@10': '0.5192', 'NDCG@10': '0.3297', 'MRR': '0.2896'} 90 | {'epoch': 44, 'rec_avg_loss': '0.4604', 'rec_cur_loss': '0.3949'} 91 | {'Epoch': 44, 'HIT@1': '0.1771', 'NDCG@1': '0.1771', 'HIT@5': '0.3945', 'NDCG@5': '0.2895', 'HIT@10': '0.5181', 'NDCG@10': '0.3294', 'MRR': '0.2896'} 92 | {'epoch': 45, 'rec_avg_loss': '0.4561', 'rec_cur_loss': '0.5135'} 93 | {'Epoch': 45, 'HIT@1': '0.1762', 'NDCG@1': '0.1762', 'HIT@5': '0.3941', 'NDCG@5': '0.2890', 'HIT@10': '0.5176', 'NDCG@10': '0.3288', 'MRR': '0.2890'} 94 | {'epoch': 46, 'rec_avg_loss': '0.4591', 'rec_cur_loss': '0.6178'} 95 | {'Epoch': 46, 'HIT@1': '0.1748', 'NDCG@1': '0.1748', 'HIT@5': '0.3920', 'NDCG@5': '0.2873', 'HIT@10': '0.5174', 'NDCG@10': '0.3277', 'MRR': '0.2876'} 96 | {'epoch': 47, 'rec_avg_loss': '0.4513', 'rec_cur_loss': '0.3304'} 97 | {'Epoch': 47, 'HIT@1': '0.1735', 'NDCG@1': '0.1735', 'HIT@5': '0.3966', 'NDCG@5': '0.2889', 'HIT@10': '0.5208', 'NDCG@10': '0.3290', 'MRR': '0.2880'} 98 | {'epoch': 48, 'rec_avg_loss': '0.4528', 'rec_cur_loss': '0.6324'} 99 | {'Epoch': 48, 'HIT@1': '0.1730', 'NDCG@1': '0.1730', 'HIT@5': '0.3945', 'NDCG@5': '0.2878', 'HIT@10': '0.5169', 'NDCG@10': '0.3273', 'MRR': '0.2872'} 100 | {'epoch': 49, 'rec_avg_loss': '0.4487', 'rec_cur_loss': '0.4355'} 101 | {'Epoch': 49, 'HIT@1': '0.1743', 'NDCG@1': '0.1743', 'HIT@5': '0.3951', 'NDCG@5': '0.2886', 'HIT@10': '0.5177', 'NDCG@10': '0.3281', 'MRR': '0.2880'} 102 | {'epoch': 50, 'rec_avg_loss': '0.4458', 'rec_cur_loss': '0.4284'} 103 | {'Epoch': 50, 'HIT@1': '0.1754', 'NDCG@1': '0.1754', 'HIT@5': '0.3960', 'NDCG@5': '0.2897', 'HIT@10': '0.5208', 'NDCG@10': '0.3299', 'MRR': '0.2893'} 104 | {'epoch': 51, 'rec_avg_loss': '0.4457', 'rec_cur_loss': '0.6274'} 105 | {'Epoch': 51, 'HIT@1': '0.1773', 'NDCG@1': '0.1773', 'HIT@5': '0.3962', 'NDCG@5': '0.2904', 'HIT@10': '0.5212', 'NDCG@10': '0.3306', 'MRR': '0.2901'} 106 | {'epoch': 52, 'rec_avg_loss': '0.4387', 'rec_cur_loss': '0.2884'} 107 | {'Epoch': 52, 'HIT@1': '0.1770', 'NDCG@1': '0.1770', 'HIT@5': '0.3975', 'NDCG@5': '0.2912', 'HIT@10': '0.5212', 'NDCG@10': '0.3311', 'MRR': '0.2906'} 108 | {'epoch': 53, 'rec_avg_loss': '0.4417', 'rec_cur_loss': '0.5764'} 109 | {'Epoch': 53, 'HIT@1': '0.1784', 'NDCG@1': '0.1784', 'HIT@5': '0.3989', 'NDCG@5': '0.2922', 'HIT@10': '0.5216', 'NDCG@10': '0.3318', 'MRR': '0.2914'} 110 | {'epoch': 54, 'rec_avg_loss': '0.4414', 'rec_cur_loss': '0.3727'} 111 | {'Epoch': 54, 'HIT@1': '0.1771', 'NDCG@1': '0.1771', 'HIT@5': '0.3965', 'NDCG@5': '0.2909', 'HIT@10': '0.5210', 'NDCG@10': '0.3311', 'MRR': '0.2907'} 112 | {'epoch': 55, 'rec_avg_loss': '0.4366', 'rec_cur_loss': '0.4358'} 113 | {'Epoch': 55, 'HIT@1': '0.1760', 'NDCG@1': '0.1760', 'HIT@5': '0.3944', 'NDCG@5': '0.2890', 'HIT@10': '0.5185', 'NDCG@10': '0.3291', 'MRR': '0.2890'} 114 | {'epoch': 56, 'rec_avg_loss': '0.4379', 'rec_cur_loss': '0.5245'} 115 | {'Epoch': 56, 'HIT@1': '0.1754', 'NDCG@1': '0.1754', 'HIT@5': '0.3974', 'NDCG@5': '0.2905', 'HIT@10': '0.5189', 'NDCG@10': '0.3298', 'MRR': '0.2896'} 116 | {'epoch': 57, 'rec_avg_loss': '0.4358', 'rec_cur_loss': '0.4881'} 117 | {'Epoch': 57, 'HIT@1': '0.1735', 'NDCG@1': '0.1735', 'HIT@5': '0.3958', 'NDCG@5': '0.2886', 'HIT@10': '0.5196', 'NDCG@10': '0.3285', 'MRR': '0.2878'} 118 | {'epoch': 58, 'rec_avg_loss': '0.4332', 'rec_cur_loss': '0.3695'} 119 | {'Epoch': 58, 'HIT@1': '0.1770', 'NDCG@1': '0.1770', 'HIT@5': '0.3957', 'NDCG@5': '0.2901', 'HIT@10': '0.5187', 'NDCG@10': '0.3298', 'MRR': '0.2898'} 120 | {'epoch': 59, 'rec_avg_loss': '0.4310', 'rec_cur_loss': '0.4137'} 121 | {'Epoch': 59, 'HIT@1': '0.1776', 'NDCG@1': '0.1776', 'HIT@5': '0.3979', 'NDCG@5': '0.2917', 'HIT@10': '0.5192', 'NDCG@10': '0.3309', 'MRR': '0.2912'} 122 | {'epoch': 60, 'rec_avg_loss': '0.4332', 'rec_cur_loss': '0.3438'} 123 | {'Epoch': 60, 'HIT@1': '0.1776', 'NDCG@1': '0.1776', 'HIT@5': '0.3970', 'NDCG@5': '0.2912', 'HIT@10': '0.5226', 'NDCG@10': '0.3318', 'MRR': '0.2910'} 124 | {'epoch': 61, 'rec_avg_loss': '0.4301', 'rec_cur_loss': '0.4094'} 125 | {'Epoch': 61, 'HIT@1': '0.1774', 'NDCG@1': '0.1774', 'HIT@5': '0.3977', 'NDCG@5': '0.2914', 'HIT@10': '0.5222', 'NDCG@10': '0.3316', 'MRR': '0.2909'} 126 | {'epoch': 62, 'rec_avg_loss': '0.4261', 'rec_cur_loss': '0.5105'} 127 | {'Epoch': 62, 'HIT@1': '0.1753', 'NDCG@1': '0.1753', 'HIT@5': '0.3950', 'NDCG@5': '0.2892', 'HIT@10': '0.5211', 'NDCG@10': '0.3299', 'MRR': '0.2891'} 128 | {'epoch': 63, 'rec_avg_loss': '0.4296', 'rec_cur_loss': '0.3446'} 129 | {'Epoch': 63, 'HIT@1': '0.1758', 'NDCG@1': '0.1758', 'HIT@5': '0.3963', 'NDCG@5': '0.2897', 'HIT@10': '0.5205', 'NDCG@10': '0.3298', 'MRR': '0.2893'} 130 | {'Epoch': 0, 'HIT@1': '0.1472', 'NDCG@1': '0.1472', 'HIT@5': '0.3441', 'NDCG@5': '0.2487', 'HIT@10': '0.4645', 'NDCG@10': '0.2875', 'MRR': '0.2524'} 131 | Finetune_sample-Sports_and_Outdoors-0 132 | {'Epoch': 0, 'HIT@1': '0.1472', 'NDCG@1': '0.1472', 'HIT@5': '0.3441', 'NDCG@5': '0.2487', 'HIT@10': '0.4645', 'NDCG@10': '0.2875', 'MRR': '0.2524'} 133 | -------------------------------------------------------------------------------- /reproduce/Finetune_sample-Sports_and_Outdoors-100.txt: -------------------------------------------------------------------------------- 1 | Namespace(adam_beta1=0.9, adam_beta2=0.999, attention_probs_dropout_prob=0.5, attribute_size=2278, batch_size=256, ckp=100, cuda_condition=True, data_dir='../TOIS/data/', data_file='../TOIS/data/Sports_and_Outdoors.txt', data_name='Sports_and_Outdoors', do_eval=False, epochs=200, gpu_id='0', hidden_act='gelu', hidden_dropout_prob=0.5, hidden_size=64, initializer_range=0.02, item_size=18359, log_file='output/Finetune_sample-Sports_and_Outdoors-100.txt', log_freq=1, lr=0.001, mask_id=18358, max_seq_length=50, model_name='Finetune_sample', no_cuda=False, num_attention_heads=2, num_hidden_layers=2, output_dir='output/', sample_file='../TOIS/data/Sports_and_Outdoors_sample.txt', seed=42, weight_decay=0.0) 2 | {'epoch': 0, 'rec_avg_loss': '0.9668', 'rec_cur_loss': '0.8626'} 3 | {'Epoch': 0, 'HIT@1': '0.1733', 'NDCG@1': '0.1733', 'HIT@5': '0.4221', 'NDCG@5': '0.3018', 'HIT@10': '0.5700', 'NDCG@10': '0.3496', 'MRR': '0.2999'} 4 | {'epoch': 1, 'rec_avg_loss': '0.8767', 'rec_cur_loss': '0.9390'} 5 | {'Epoch': 1, 'HIT@1': '0.1865', 'NDCG@1': '0.1865', 'HIT@5': '0.4424', 'NDCG@5': '0.3188', 'HIT@10': '0.5849', 'NDCG@10': '0.3649', 'MRR': '0.3146'} 6 | {'epoch': 2, 'rec_avg_loss': '0.8479', 'rec_cur_loss': '0.8178'} 7 | {'Epoch': 2, 'HIT@1': '0.1928', 'NDCG@1': '0.1928', 'HIT@5': '0.4530', 'NDCG@5': '0.3271', 'HIT@10': '0.5919', 'NDCG@10': '0.3720', 'MRR': '0.3213'} 8 | {'epoch': 3, 'rec_avg_loss': '0.8297', 'rec_cur_loss': '0.6934'} 9 | {'Epoch': 3, 'HIT@1': '0.1969', 'NDCG@1': '0.1969', 'HIT@5': '0.4575', 'NDCG@5': '0.3316', 'HIT@10': '0.5966', 'NDCG@10': '0.3765', 'MRR': '0.3255'} 10 | {'epoch': 4, 'rec_avg_loss': '0.8130', 'rec_cur_loss': '0.6916'} 11 | {'Epoch': 4, 'HIT@1': '0.1993', 'NDCG@1': '0.1993', 'HIT@5': '0.4628', 'NDCG@5': '0.3358', 'HIT@10': '0.6001', 'NDCG@10': '0.3802', 'MRR': '0.3291'} 12 | {'epoch': 5, 'rec_avg_loss': '0.8031', 'rec_cur_loss': '0.7980'} 13 | {'Epoch': 5, 'HIT@1': '0.2004', 'NDCG@1': '0.2004', 'HIT@5': '0.4635', 'NDCG@5': '0.3365', 'HIT@10': '0.6016', 'NDCG@10': '0.3812', 'MRR': '0.3298'} 14 | {'epoch': 6, 'rec_avg_loss': '0.7937', 'rec_cur_loss': '0.6053'} 15 | {'Epoch': 6, 'HIT@1': '0.2027', 'NDCG@1': '0.2027', 'HIT@5': '0.4670', 'NDCG@5': '0.3398', 'HIT@10': '0.6041', 'NDCG@10': '0.3842', 'MRR': '0.3328'} 16 | {'epoch': 7, 'rec_avg_loss': '0.7861', 'rec_cur_loss': '0.7025'} 17 | {'Epoch': 7, 'HIT@1': '0.2060', 'NDCG@1': '0.2060', 'HIT@5': '0.4700', 'NDCG@5': '0.3430', 'HIT@10': '0.6076', 'NDCG@10': '0.3875', 'MRR': '0.3359'} 18 | {'epoch': 8, 'rec_avg_loss': '0.7778', 'rec_cur_loss': '0.8324'} 19 | {'Epoch': 8, 'HIT@1': '0.2076', 'NDCG@1': '0.2076', 'HIT@5': '0.4710', 'NDCG@5': '0.3443', 'HIT@10': '0.6081', 'NDCG@10': '0.3886', 'MRR': '0.3372'} 20 | {'epoch': 9, 'rec_avg_loss': '0.7690', 'rec_cur_loss': '0.7084'} 21 | {'Epoch': 9, 'HIT@1': '0.2092', 'NDCG@1': '0.2092', 'HIT@5': '0.4728', 'NDCG@5': '0.3461', 'HIT@10': '0.6090', 'NDCG@10': '0.3901', 'MRR': '0.3388'} 22 | {'epoch': 10, 'rec_avg_loss': '0.7609', 'rec_cur_loss': '0.5610'} 23 | {'Epoch': 10, 'HIT@1': '0.2103', 'NDCG@1': '0.2103', 'HIT@5': '0.4725', 'NDCG@5': '0.3463', 'HIT@10': '0.6085', 'NDCG@10': '0.3904', 'MRR': '0.3394'} 24 | {'epoch': 11, 'rec_avg_loss': '0.7554', 'rec_cur_loss': '0.8314'} 25 | {'Epoch': 11, 'HIT@1': '0.2105', 'NDCG@1': '0.2105', 'HIT@5': '0.4758', 'NDCG@5': '0.3483', 'HIT@10': '0.6119', 'NDCG@10': '0.3923', 'MRR': '0.3407'} 26 | {'epoch': 12, 'rec_avg_loss': '0.7508', 'rec_cur_loss': '0.7584'} 27 | {'Epoch': 12, 'HIT@1': '0.2118', 'NDCG@1': '0.2118', 'HIT@5': '0.4783', 'NDCG@5': '0.3504', 'HIT@10': '0.6107', 'NDCG@10': '0.3931', 'MRR': '0.3421'} 28 | {'epoch': 13, 'rec_avg_loss': '0.7481', 'rec_cur_loss': '1.1468'} 29 | {'Epoch': 13, 'HIT@1': '0.2131', 'NDCG@1': '0.2131', 'HIT@5': '0.4795', 'NDCG@5': '0.3519', 'HIT@10': '0.6121', 'NDCG@10': '0.3948', 'MRR': '0.3438'} 30 | {'epoch': 14, 'rec_avg_loss': '0.7396', 'rec_cur_loss': '0.7190'} 31 | {'Epoch': 14, 'HIT@1': '0.2159', 'NDCG@1': '0.2159', 'HIT@5': '0.4807', 'NDCG@5': '0.3536', 'HIT@10': '0.6146', 'NDCG@10': '0.3970', 'MRR': '0.3458'} 32 | {'epoch': 15, 'rec_avg_loss': '0.7361', 'rec_cur_loss': '0.7843'} 33 | {'Epoch': 15, 'HIT@1': '0.2153', 'NDCG@1': '0.2153', 'HIT@5': '0.4811', 'NDCG@5': '0.3536', 'HIT@10': '0.6148', 'NDCG@10': '0.3967', 'MRR': '0.3454'} 34 | {'epoch': 16, 'rec_avg_loss': '0.7260', 'rec_cur_loss': '0.6487'} 35 | {'Epoch': 16, 'HIT@1': '0.2159', 'NDCG@1': '0.2159', 'HIT@5': '0.4806', 'NDCG@5': '0.3534', 'HIT@10': '0.6144', 'NDCG@10': '0.3967', 'MRR': '0.3455'} 36 | {'epoch': 17, 'rec_avg_loss': '0.7207', 'rec_cur_loss': '0.7814'} 37 | {'Epoch': 17, 'HIT@1': '0.2164', 'NDCG@1': '0.2164', 'HIT@5': '0.4830', 'NDCG@5': '0.3548', 'HIT@10': '0.6159', 'NDCG@10': '0.3976', 'MRR': '0.3462'} 38 | {'epoch': 18, 'rec_avg_loss': '0.7192', 'rec_cur_loss': '0.9357'} 39 | {'Epoch': 18, 'HIT@1': '0.2179', 'NDCG@1': '0.2179', 'HIT@5': '0.4831', 'NDCG@5': '0.3560', 'HIT@10': '0.6171', 'NDCG@10': '0.3993', 'MRR': '0.3480'} 40 | {'epoch': 19, 'rec_avg_loss': '0.7157', 'rec_cur_loss': '0.6599'} 41 | {'Epoch': 19, 'HIT@1': '0.2187', 'NDCG@1': '0.2187', 'HIT@5': '0.4837', 'NDCG@5': '0.3564', 'HIT@10': '0.6176', 'NDCG@10': '0.3996', 'MRR': '0.3482'} 42 | {'epoch': 20, 'rec_avg_loss': '0.7087', 'rec_cur_loss': '0.6483'} 43 | {'Epoch': 20, 'HIT@1': '0.2181', 'NDCG@1': '0.2181', 'HIT@5': '0.4842', 'NDCG@5': '0.3564', 'HIT@10': '0.6171', 'NDCG@10': '0.3993', 'MRR': '0.3480'} 44 | {'epoch': 21, 'rec_avg_loss': '0.7031', 'rec_cur_loss': '0.9315'} 45 | {'Epoch': 21, 'HIT@1': '0.2189', 'NDCG@1': '0.2189', 'HIT@5': '0.4827', 'NDCG@5': '0.3564', 'HIT@10': '0.6186', 'NDCG@10': '0.4003', 'MRR': '0.3486'} 46 | {'epoch': 22, 'rec_avg_loss': '0.6971', 'rec_cur_loss': '0.7864'} 47 | {'Epoch': 22, 'HIT@1': '0.2180', 'NDCG@1': '0.2180', 'HIT@5': '0.4833', 'NDCG@5': '0.3564', 'HIT@10': '0.6158', 'NDCG@10': '0.3993', 'MRR': '0.3483'} 48 | {'epoch': 23, 'rec_avg_loss': '0.6974', 'rec_cur_loss': '0.6703'} 49 | {'Epoch': 23, 'HIT@1': '0.2201', 'NDCG@1': '0.2201', 'HIT@5': '0.4854', 'NDCG@5': '0.3585', 'HIT@10': '0.6183', 'NDCG@10': '0.4015', 'MRR': '0.3503'} 50 | {'epoch': 24, 'rec_avg_loss': '0.6876', 'rec_cur_loss': '0.5827'} 51 | {'Epoch': 24, 'HIT@1': '0.2197', 'NDCG@1': '0.2197', 'HIT@5': '0.4860', 'NDCG@5': '0.3587', 'HIT@10': '0.6179', 'NDCG@10': '0.4014', 'MRR': '0.3503'} 52 | {'epoch': 25, 'rec_avg_loss': '0.6866', 'rec_cur_loss': '0.6588'} 53 | {'Epoch': 25, 'HIT@1': '0.2184', 'NDCG@1': '0.2184', 'HIT@5': '0.4840', 'NDCG@5': '0.3572', 'HIT@10': '0.6177', 'NDCG@10': '0.4004', 'MRR': '0.3490'} 54 | {'epoch': 26, 'rec_avg_loss': '0.6822', 'rec_cur_loss': '0.8172'} 55 | {'Epoch': 26, 'HIT@1': '0.2200', 'NDCG@1': '0.2200', 'HIT@5': '0.4856', 'NDCG@5': '0.3584', 'HIT@10': '0.6176', 'NDCG@10': '0.4011', 'MRR': '0.3500'} 56 | {'epoch': 27, 'rec_avg_loss': '0.6765', 'rec_cur_loss': '0.8277'} 57 | {'Epoch': 27, 'HIT@1': '0.2208', 'NDCG@1': '0.2208', 'HIT@5': '0.4851', 'NDCG@5': '0.3588', 'HIT@10': '0.6197', 'NDCG@10': '0.4023', 'MRR': '0.3509'} 58 | {'epoch': 28, 'rec_avg_loss': '0.6718', 'rec_cur_loss': '0.7248'} 59 | {'Epoch': 28, 'HIT@1': '0.2224', 'NDCG@1': '0.2224', 'HIT@5': '0.4864', 'NDCG@5': '0.3601', 'HIT@10': '0.6204', 'NDCG@10': '0.4033', 'MRR': '0.3520'} 60 | {'epoch': 29, 'rec_avg_loss': '0.6709', 'rec_cur_loss': '0.6226'} 61 | {'Epoch': 29, 'HIT@1': '0.2216', 'NDCG@1': '0.2216', 'HIT@5': '0.4864', 'NDCG@5': '0.3598', 'HIT@10': '0.6193', 'NDCG@10': '0.4027', 'MRR': '0.3515'} 62 | {'epoch': 30, 'rec_avg_loss': '0.6662', 'rec_cur_loss': '0.7776'} 63 | {'Epoch': 30, 'HIT@1': '0.2207', 'NDCG@1': '0.2207', 'HIT@5': '0.4875', 'NDCG@5': '0.3600', 'HIT@10': '0.6184', 'NDCG@10': '0.4024', 'MRR': '0.3514'} 64 | {'epoch': 31, 'rec_avg_loss': '0.6584', 'rec_cur_loss': '0.6980'} 65 | {'Epoch': 31, 'HIT@1': '0.2194', 'NDCG@1': '0.2194', 'HIT@5': '0.4849', 'NDCG@5': '0.3581', 'HIT@10': '0.6171', 'NDCG@10': '0.4009', 'MRR': '0.3499'} 66 | {'epoch': 32, 'rec_avg_loss': '0.6568', 'rec_cur_loss': '0.6971'} 67 | {'Epoch': 32, 'HIT@1': '0.2216', 'NDCG@1': '0.2216', 'HIT@5': '0.4881', 'NDCG@5': '0.3608', 'HIT@10': '0.6182', 'NDCG@10': '0.4028', 'MRR': '0.3519'} 68 | {'epoch': 33, 'rec_avg_loss': '0.6545', 'rec_cur_loss': '0.4513'} 69 | {'Epoch': 33, 'HIT@1': '0.2219', 'NDCG@1': '0.2219', 'HIT@5': '0.4854', 'NDCG@5': '0.3597', 'HIT@10': '0.6187', 'NDCG@10': '0.4028', 'MRR': '0.3518'} 70 | {'epoch': 34, 'rec_avg_loss': '0.6501', 'rec_cur_loss': '0.7791'} 71 | {'Epoch': 34, 'HIT@1': '0.2232', 'NDCG@1': '0.2232', 'HIT@5': '0.4867', 'NDCG@5': '0.3608', 'HIT@10': '0.6189', 'NDCG@10': '0.4036', 'MRR': '0.3527'} 72 | {'epoch': 35, 'rec_avg_loss': '0.6487', 'rec_cur_loss': '0.5581'} 73 | {'Epoch': 35, 'HIT@1': '0.2237', 'NDCG@1': '0.2237', 'HIT@5': '0.4850', 'NDCG@5': '0.3603', 'HIT@10': '0.6181', 'NDCG@10': '0.4033', 'MRR': '0.3526'} 74 | {'epoch': 36, 'rec_avg_loss': '0.6417', 'rec_cur_loss': '0.7053'} 75 | {'Epoch': 36, 'HIT@1': '0.2229', 'NDCG@1': '0.2229', 'HIT@5': '0.4863', 'NDCG@5': '0.3607', 'HIT@10': '0.6185', 'NDCG@10': '0.4034', 'MRR': '0.3525'} 76 | {'epoch': 37, 'rec_avg_loss': '0.6437', 'rec_cur_loss': '0.7684'} 77 | {'Epoch': 37, 'HIT@1': '0.2235', 'NDCG@1': '0.2235', 'HIT@5': '0.4876', 'NDCG@5': '0.3614', 'HIT@10': '0.6173', 'NDCG@10': '0.4033', 'MRR': '0.3529'} 78 | {'epoch': 38, 'rec_avg_loss': '0.6351', 'rec_cur_loss': '0.5924'} 79 | {'Epoch': 38, 'HIT@1': '0.2233', 'NDCG@1': '0.2233', 'HIT@5': '0.4880', 'NDCG@5': '0.3614', 'HIT@10': '0.6180', 'NDCG@10': '0.4034', 'MRR': '0.3528'} 80 | {'epoch': 39, 'rec_avg_loss': '0.6333', 'rec_cur_loss': '0.6404'} 81 | {'Epoch': 39, 'HIT@1': '0.2227', 'NDCG@1': '0.2227', 'HIT@5': '0.4845', 'NDCG@5': '0.3597', 'HIT@10': '0.6163', 'NDCG@10': '0.4023', 'MRR': '0.3519'} 82 | {'epoch': 40, 'rec_avg_loss': '0.6290', 'rec_cur_loss': '0.5301'} 83 | {'Epoch': 40, 'HIT@1': '0.2243', 'NDCG@1': '0.2243', 'HIT@5': '0.4861', 'NDCG@5': '0.3608', 'HIT@10': '0.6169', 'NDCG@10': '0.4031', 'MRR': '0.3527'} 84 | {'epoch': 41, 'rec_avg_loss': '0.6245', 'rec_cur_loss': '0.6079'} 85 | {'Epoch': 41, 'HIT@1': '0.2234', 'NDCG@1': '0.2234', 'HIT@5': '0.4866', 'NDCG@5': '0.3609', 'HIT@10': '0.6169', 'NDCG@10': '0.4030', 'MRR': '0.3525'} 86 | {'epoch': 42, 'rec_avg_loss': '0.6257', 'rec_cur_loss': '0.9753'} 87 | {'Epoch': 42, 'HIT@1': '0.2234', 'NDCG@1': '0.2234', 'HIT@5': '0.4858', 'NDCG@5': '0.3606', 'HIT@10': '0.6176', 'NDCG@10': '0.4032', 'MRR': '0.3526'} 88 | {'epoch': 43, 'rec_avg_loss': '0.6203', 'rec_cur_loss': '0.6089'} 89 | {'Epoch': 43, 'HIT@1': '0.2221', 'NDCG@1': '0.2221', 'HIT@5': '0.4862', 'NDCG@5': '0.3599', 'HIT@10': '0.6165', 'NDCG@10': '0.4020', 'MRR': '0.3513'} 90 | {'epoch': 44, 'rec_avg_loss': '0.6202', 'rec_cur_loss': '0.5950'} 91 | {'Epoch': 44, 'HIT@1': '0.2236', 'NDCG@1': '0.2236', 'HIT@5': '0.4859', 'NDCG@5': '0.3604', 'HIT@10': '0.6147', 'NDCG@10': '0.4021', 'MRR': '0.3521'} 92 | {'epoch': 45, 'rec_avg_loss': '0.6149', 'rec_cur_loss': '0.7537'} 93 | {'Epoch': 45, 'HIT@1': '0.2239', 'NDCG@1': '0.2239', 'HIT@5': '0.4863', 'NDCG@5': '0.3608', 'HIT@10': '0.6173', 'NDCG@10': '0.4031', 'MRR': '0.3525'} 94 | {'epoch': 46, 'rec_avg_loss': '0.6135', 'rec_cur_loss': '0.6624'} 95 | {'Epoch': 46, 'HIT@1': '0.2230', 'NDCG@1': '0.2230', 'HIT@5': '0.4857', 'NDCG@5': '0.3602', 'HIT@10': '0.6155', 'NDCG@10': '0.4021', 'MRR': '0.3518'} 96 | {'epoch': 47, 'rec_avg_loss': '0.6068', 'rec_cur_loss': '0.5226'} 97 | {'Epoch': 47, 'HIT@1': '0.2215', 'NDCG@1': '0.2215', 'HIT@5': '0.4861', 'NDCG@5': '0.3598', 'HIT@10': '0.6144', 'NDCG@10': '0.4012', 'MRR': '0.3511'} 98 | {'Epoch': 0, 'HIT@1': '0.1840', 'NDCG@1': '0.1840', 'HIT@5': '0.4319', 'NDCG@5': '0.3125', 'HIT@10': '0.5664', 'NDCG@10': '0.3559', 'MRR': '0.3084'} 99 | Finetune_sample-Sports_and_Outdoors-100 100 | {'Epoch': 0, 'HIT@1': '0.1840', 'NDCG@1': '0.1840', 'HIT@5': '0.4319', 'NDCG@5': '0.3125', 'HIT@10': '0.5664', 'NDCG@10': '0.3559', 'MRR': '0.3084'} 101 | -------------------------------------------------------------------------------- /reproduce/Finetune_sample-Toys_and_Games-0.txt: -------------------------------------------------------------------------------- 1 | Namespace(adam_beta1=0.9, adam_beta2=0.999, attention_probs_dropout_prob=0.5, attribute_size=1028, batch_size=256, ckp=0, cuda_condition=True, data_dir='../TOIS/data/', data_file='../TOIS/data/Toys_and_Games.txt', data_name='Toys_and_Games', do_eval=False, epochs=200, gpu_id='0', hidden_act='gelu', hidden_dropout_prob=0.5, hidden_size=64, initializer_range=0.02, item_size=11926, log_file='output/Finetune_sample-Toys_and_Games-0.txt', log_freq=1, lr=0.001, mask_id=11925, max_seq_length=50, model_name='Finetune_sample', no_cuda=False, num_attention_heads=2, num_hidden_layers=2, output_dir='output/', sample_file='../TOIS/data/Toys_and_Games_sample.txt', seed=42, weight_decay=0.0) 2 | {'epoch': 0, 'rec_avg_loss': '1.3617', 'rec_cur_loss': '1.2990'} 3 | {'Epoch': 0, 'HIT@1': '0.0631', 'NDCG@1': '0.0631', 'HIT@5': '0.1785', 'NDCG@5': '0.1217', 'HIT@10': '0.2748', 'NDCG@10': '0.1527', 'MRR': '0.1376'} 4 | {'epoch': 1, 'rec_avg_loss': '1.2411', 'rec_cur_loss': '1.2175'} 5 | {'Epoch': 1, 'HIT@1': '0.0656', 'NDCG@1': '0.0656', 'HIT@5': '0.1929', 'NDCG@5': '0.1298', 'HIT@10': '0.2969', 'NDCG@10': '0.1633', 'MRR': '0.1451'} 6 | {'epoch': 2, 'rec_avg_loss': '1.1764', 'rec_cur_loss': '1.1873'} 7 | {'Epoch': 2, 'HIT@1': '0.0730', 'NDCG@1': '0.0730', 'HIT@5': '0.2174', 'NDCG@5': '0.1457', 'HIT@10': '0.3287', 'NDCG@10': '0.1814', 'MRR': '0.1579'} 8 | {'epoch': 3, 'rec_avg_loss': '1.1154', 'rec_cur_loss': '1.1342'} 9 | {'Epoch': 3, 'HIT@1': '0.0779', 'NDCG@1': '0.0779', 'HIT@5': '0.2356', 'NDCG@5': '0.1575', 'HIT@10': '0.3495', 'NDCG@10': '0.1942', 'MRR': '0.1678'} 10 | {'epoch': 4, 'rec_avg_loss': '1.0608', 'rec_cur_loss': '1.0176'} 11 | {'Epoch': 4, 'HIT@1': '0.0906', 'NDCG@1': '0.0906', 'HIT@5': '0.2587', 'NDCG@5': '0.1757', 'HIT@10': '0.3730', 'NDCG@10': '0.2125', 'MRR': '0.1839'} 12 | {'epoch': 5, 'rec_avg_loss': '1.0086', 'rec_cur_loss': '1.0016'} 13 | {'Epoch': 5, 'HIT@1': '0.1068', 'NDCG@1': '0.1068', 'HIT@5': '0.2829', 'NDCG@5': '0.1961', 'HIT@10': '0.4001', 'NDCG@10': '0.2340', 'MRR': '0.2027'} 14 | {'epoch': 6, 'rec_avg_loss': '0.9548', 'rec_cur_loss': '0.9278'} 15 | {'Epoch': 6, 'HIT@1': '0.1242', 'NDCG@1': '0.1242', 'HIT@5': '0.3108', 'NDCG@5': '0.2193', 'HIT@10': '0.4270', 'NDCG@10': '0.2569', 'MRR': '0.2234'} 16 | {'epoch': 7, 'rec_avg_loss': '0.9072', 'rec_cur_loss': '0.9558'} 17 | {'Epoch': 7, 'HIT@1': '0.1345', 'NDCG@1': '0.1345', 'HIT@5': '0.3272', 'NDCG@5': '0.2335', 'HIT@10': '0.4407', 'NDCG@10': '0.2702', 'MRR': '0.2362'} 18 | {'epoch': 8, 'rec_avg_loss': '0.8587', 'rec_cur_loss': '0.8582'} 19 | {'Epoch': 8, 'HIT@1': '0.1459', 'NDCG@1': '0.1459', 'HIT@5': '0.3436', 'NDCG@5': '0.2478', 'HIT@10': '0.4587', 'NDCG@10': '0.2850', 'MRR': '0.2496'} 20 | {'epoch': 9, 'rec_avg_loss': '0.8126', 'rec_cur_loss': '0.8240'} 21 | {'Epoch': 9, 'HIT@1': '0.1502', 'NDCG@1': '0.1502', 'HIT@5': '0.3541', 'NDCG@5': '0.2556', 'HIT@10': '0.4667', 'NDCG@10': '0.2920', 'MRR': '0.2560'} 22 | {'epoch': 10, 'rec_avg_loss': '0.7725', 'rec_cur_loss': '0.8048'} 23 | {'Epoch': 10, 'HIT@1': '0.1558', 'NDCG@1': '0.1558', 'HIT@5': '0.3630', 'NDCG@5': '0.2626', 'HIT@10': '0.4730', 'NDCG@10': '0.2981', 'MRR': '0.2619'} 24 | {'epoch': 11, 'rec_avg_loss': '0.7379', 'rec_cur_loss': '0.7256'} 25 | {'Epoch': 11, 'HIT@1': '0.1643', 'NDCG@1': '0.1643', 'HIT@5': '0.3712', 'NDCG@5': '0.2713', 'HIT@10': '0.4808', 'NDCG@10': '0.3067', 'MRR': '0.2706'} 26 | {'epoch': 12, 'rec_avg_loss': '0.7049', 'rec_cur_loss': '0.7573'} 27 | {'Epoch': 12, 'HIT@1': '0.1676', 'NDCG@1': '0.1676', 'HIT@5': '0.3752', 'NDCG@5': '0.2751', 'HIT@10': '0.4856', 'NDCG@10': '0.3109', 'MRR': '0.2745'} 28 | {'epoch': 13, 'rec_avg_loss': '0.6774', 'rec_cur_loss': '0.6648'} 29 | {'Epoch': 13, 'HIT@1': '0.1738', 'NDCG@1': '0.1738', 'HIT@5': '0.3832', 'NDCG@5': '0.2824', 'HIT@10': '0.4918', 'NDCG@10': '0.3175', 'MRR': '0.2808'} 30 | {'epoch': 14, 'rec_avg_loss': '0.6512', 'rec_cur_loss': '0.6258'} 31 | {'Epoch': 14, 'HIT@1': '0.1743', 'NDCG@1': '0.1743', 'HIT@5': '0.3863', 'NDCG@5': '0.2846', 'HIT@10': '0.4966', 'NDCG@10': '0.3202', 'MRR': '0.2828'} 32 | {'epoch': 15, 'rec_avg_loss': '0.6279', 'rec_cur_loss': '0.6401'} 33 | {'Epoch': 15, 'HIT@1': '0.1791', 'NDCG@1': '0.1791', 'HIT@5': '0.3907', 'NDCG@5': '0.2890', 'HIT@10': '0.4967', 'NDCG@10': '0.3234', 'MRR': '0.2870'} 34 | {'epoch': 16, 'rec_avg_loss': '0.6082', 'rec_cur_loss': '0.6307'} 35 | {'Epoch': 16, 'HIT@1': '0.1805', 'NDCG@1': '0.1805', 'HIT@5': '0.3935', 'NDCG@5': '0.2912', 'HIT@10': '0.5010', 'NDCG@10': '0.3260', 'MRR': '0.2889'} 36 | {'epoch': 17, 'rec_avg_loss': '0.5903', 'rec_cur_loss': '0.6017'} 37 | {'Epoch': 17, 'HIT@1': '0.1823', 'NDCG@1': '0.1823', 'HIT@5': '0.3977', 'NDCG@5': '0.2941', 'HIT@10': '0.5002', 'NDCG@10': '0.3272', 'MRR': '0.2908'} 38 | {'epoch': 18, 'rec_avg_loss': '0.5733', 'rec_cur_loss': '0.6152'} 39 | {'Epoch': 18, 'HIT@1': '0.1860', 'NDCG@1': '0.1860', 'HIT@5': '0.3978', 'NDCG@5': '0.2958', 'HIT@10': '0.5006', 'NDCG@10': '0.3291', 'MRR': '0.2931'} 40 | {'epoch': 19, 'rec_avg_loss': '0.5561', 'rec_cur_loss': '0.5483'} 41 | {'Epoch': 19, 'HIT@1': '0.1875', 'NDCG@1': '0.1875', 'HIT@5': '0.4000', 'NDCG@5': '0.2984', 'HIT@10': '0.5029', 'NDCG@10': '0.3316', 'MRR': '0.2957'} 42 | {'epoch': 20, 'rec_avg_loss': '0.5404', 'rec_cur_loss': '0.5484'} 43 | {'Epoch': 20, 'HIT@1': '0.1900', 'NDCG@1': '0.1900', 'HIT@5': '0.4022', 'NDCG@5': '0.3004', 'HIT@10': '0.5050', 'NDCG@10': '0.3336', 'MRR': '0.2976'} 44 | {'epoch': 21, 'rec_avg_loss': '0.5278', 'rec_cur_loss': '0.5628'} 45 | {'Epoch': 21, 'HIT@1': '0.1924', 'NDCG@1': '0.1924', 'HIT@5': '0.4038', 'NDCG@5': '0.3023', 'HIT@10': '0.5078', 'NDCG@10': '0.3359', 'MRR': '0.2998'} 46 | {'epoch': 22, 'rec_avg_loss': '0.5183', 'rec_cur_loss': '0.5089'} 47 | {'Epoch': 22, 'HIT@1': '0.1932', 'NDCG@1': '0.1932', 'HIT@5': '0.4053', 'NDCG@5': '0.3038', 'HIT@10': '0.5086', 'NDCG@10': '0.3372', 'MRR': '0.3011'} 48 | {'epoch': 23, 'rec_avg_loss': '0.5051', 'rec_cur_loss': '0.5585'} 49 | {'Epoch': 23, 'HIT@1': '0.1947', 'NDCG@1': '0.1947', 'HIT@5': '0.4055', 'NDCG@5': '0.3044', 'HIT@10': '0.5054', 'NDCG@10': '0.3368', 'MRR': '0.3017'} 50 | {'epoch': 24, 'rec_avg_loss': '0.4957', 'rec_cur_loss': '0.4878'} 51 | {'Epoch': 24, 'HIT@1': '0.1937', 'NDCG@1': '0.1937', 'HIT@5': '0.4052', 'NDCG@5': '0.3042', 'HIT@10': '0.5075', 'NDCG@10': '0.3373', 'MRR': '0.3016'} 52 | {'epoch': 25, 'rec_avg_loss': '0.4867', 'rec_cur_loss': '0.4999'} 53 | {'Epoch': 25, 'HIT@1': '0.1954', 'NDCG@1': '0.1954', 'HIT@5': '0.4050', 'NDCG@5': '0.3046', 'HIT@10': '0.5076', 'NDCG@10': '0.3377', 'MRR': '0.3022'} 54 | {'epoch': 26, 'rec_avg_loss': '0.4749', 'rec_cur_loss': '0.4631'} 55 | {'Epoch': 26, 'HIT@1': '0.1934', 'NDCG@1': '0.1934', 'HIT@5': '0.4030', 'NDCG@5': '0.3027', 'HIT@10': '0.5049', 'NDCG@10': '0.3356', 'MRR': '0.3004'} 56 | {'epoch': 27, 'rec_avg_loss': '0.4674', 'rec_cur_loss': '0.4585'} 57 | {'Epoch': 27, 'HIT@1': '0.1997', 'NDCG@1': '0.1997', 'HIT@5': '0.4058', 'NDCG@5': '0.3072', 'HIT@10': '0.5084', 'NDCG@10': '0.3403', 'MRR': '0.3052'} 58 | {'epoch': 28, 'rec_avg_loss': '0.4590', 'rec_cur_loss': '0.4768'} 59 | {'Epoch': 28, 'HIT@1': '0.1970', 'NDCG@1': '0.1970', 'HIT@5': '0.4089', 'NDCG@5': '0.3075', 'HIT@10': '0.5080', 'NDCG@10': '0.3396', 'MRR': '0.3043'} 60 | {'epoch': 29, 'rec_avg_loss': '0.4536', 'rec_cur_loss': '0.4849'} 61 | {'Epoch': 29, 'HIT@1': '0.1963', 'NDCG@1': '0.1963', 'HIT@5': '0.4089', 'NDCG@5': '0.3070', 'HIT@10': '0.5062', 'NDCG@10': '0.3384', 'MRR': '0.3035'} 62 | {'epoch': 30, 'rec_avg_loss': '0.4499', 'rec_cur_loss': '0.4944'} 63 | {'Epoch': 30, 'HIT@1': '0.1976', 'NDCG@1': '0.1976', 'HIT@5': '0.4074', 'NDCG@5': '0.3074', 'HIT@10': '0.5081', 'NDCG@10': '0.3399', 'MRR': '0.3048'} 64 | {'epoch': 31, 'rec_avg_loss': '0.4420', 'rec_cur_loss': '0.4638'} 65 | {'Epoch': 31, 'HIT@1': '0.1978', 'NDCG@1': '0.1978', 'HIT@5': '0.4088', 'NDCG@5': '0.3085', 'HIT@10': '0.5091', 'NDCG@10': '0.3409', 'MRR': '0.3058'} 66 | {'epoch': 32, 'rec_avg_loss': '0.4383', 'rec_cur_loss': '0.4811'} 67 | {'Epoch': 32, 'HIT@1': '0.2008', 'NDCG@1': '0.2008', 'HIT@5': '0.4080', 'NDCG@5': '0.3093', 'HIT@10': '0.5104', 'NDCG@10': '0.3423', 'MRR': '0.3072'} 68 | {'epoch': 33, 'rec_avg_loss': '0.4302', 'rec_cur_loss': '0.4213'} 69 | {'Epoch': 33, 'HIT@1': '0.1969', 'NDCG@1': '0.1969', 'HIT@5': '0.4062', 'NDCG@5': '0.3066', 'HIT@10': '0.5087', 'NDCG@10': '0.3397', 'MRR': '0.3043'} 70 | {'epoch': 34, 'rec_avg_loss': '0.4285', 'rec_cur_loss': '0.4468'} 71 | {'Epoch': 34, 'HIT@1': '0.1996', 'NDCG@1': '0.1996', 'HIT@5': '0.4099', 'NDCG@5': '0.3098', 'HIT@10': '0.5080', 'NDCG@10': '0.3414', 'MRR': '0.3069'} 72 | {'epoch': 35, 'rec_avg_loss': '0.4223', 'rec_cur_loss': '0.4230'} 73 | {'Epoch': 35, 'HIT@1': '0.1989', 'NDCG@1': '0.1989', 'HIT@5': '0.4090', 'NDCG@5': '0.3089', 'HIT@10': '0.5085', 'NDCG@10': '0.3411', 'MRR': '0.3064'} 74 | {'epoch': 36, 'rec_avg_loss': '0.4185', 'rec_cur_loss': '0.4410'} 75 | {'Epoch': 36, 'HIT@1': '0.2013', 'NDCG@1': '0.2013', 'HIT@5': '0.4083', 'NDCG@5': '0.3099', 'HIT@10': '0.5080', 'NDCG@10': '0.3421', 'MRR': '0.3078'} 76 | {'epoch': 37, 'rec_avg_loss': '0.4131', 'rec_cur_loss': '0.4553'} 77 | {'Epoch': 37, 'HIT@1': '0.2021', 'NDCG@1': '0.2021', 'HIT@5': '0.4057', 'NDCG@5': '0.3090', 'HIT@10': '0.5072', 'NDCG@10': '0.3417', 'MRR': '0.3076'} 78 | {'epoch': 38, 'rec_avg_loss': '0.4111', 'rec_cur_loss': '0.4125'} 79 | {'Epoch': 38, 'HIT@1': '0.2039', 'NDCG@1': '0.2039', 'HIT@5': '0.4085', 'NDCG@5': '0.3114', 'HIT@10': '0.5096', 'NDCG@10': '0.3439', 'MRR': '0.3096'} 80 | {'epoch': 39, 'rec_avg_loss': '0.4032', 'rec_cur_loss': '0.3866'} 81 | {'Epoch': 39, 'HIT@1': '0.2041', 'NDCG@1': '0.2041', 'HIT@5': '0.4109', 'NDCG@5': '0.3126', 'HIT@10': '0.5072', 'NDCG@10': '0.3436', 'MRR': '0.3101'} 82 | {'epoch': 40, 'rec_avg_loss': '0.4054', 'rec_cur_loss': '0.4191'} 83 | {'Epoch': 40, 'HIT@1': '0.2032', 'NDCG@1': '0.2032', 'HIT@5': '0.4095', 'NDCG@5': '0.3114', 'HIT@10': '0.5101', 'NDCG@10': '0.3439', 'MRR': '0.3094'} 84 | {'epoch': 41, 'rec_avg_loss': '0.3992', 'rec_cur_loss': '0.3951'} 85 | {'Epoch': 41, 'HIT@1': '0.2021', 'NDCG@1': '0.2021', 'HIT@5': '0.4108', 'NDCG@5': '0.3112', 'HIT@10': '0.5114', 'NDCG@10': '0.3436', 'MRR': '0.3085'} 86 | {'epoch': 42, 'rec_avg_loss': '0.3957', 'rec_cur_loss': '0.3920'} 87 | {'Epoch': 42, 'HIT@1': '0.2020', 'NDCG@1': '0.2020', 'HIT@5': '0.4092', 'NDCG@5': '0.3107', 'HIT@10': '0.5084', 'NDCG@10': '0.3427', 'MRR': '0.3085'} 88 | {'epoch': 43, 'rec_avg_loss': '0.3964', 'rec_cur_loss': '0.4165'} 89 | {'Epoch': 43, 'HIT@1': '0.2030', 'NDCG@1': '0.2030', 'HIT@5': '0.4083', 'NDCG@5': '0.3108', 'HIT@10': '0.5094', 'NDCG@10': '0.3434', 'MRR': '0.3090'} 90 | {'epoch': 44, 'rec_avg_loss': '0.3899', 'rec_cur_loss': '0.3771'} 91 | {'Epoch': 44, 'HIT@1': '0.2035', 'NDCG@1': '0.2035', 'HIT@5': '0.4109', 'NDCG@5': '0.3123', 'HIT@10': '0.5101', 'NDCG@10': '0.3444', 'MRR': '0.3100'} 92 | {'epoch': 45, 'rec_avg_loss': '0.3910', 'rec_cur_loss': '0.3985'} 93 | {'Epoch': 45, 'HIT@1': '0.2036', 'NDCG@1': '0.2036', 'HIT@5': '0.4131', 'NDCG@5': '0.3139', 'HIT@10': '0.5119', 'NDCG@10': '0.3458', 'MRR': '0.3112'} 94 | {'epoch': 46, 'rec_avg_loss': '0.3924', 'rec_cur_loss': '0.4061'} 95 | {'Epoch': 46, 'HIT@1': '0.2052', 'NDCG@1': '0.2052', 'HIT@5': '0.4122', 'NDCG@5': '0.3140', 'HIT@10': '0.5103', 'NDCG@10': '0.3456', 'MRR': '0.3116'} 96 | {'epoch': 47, 'rec_avg_loss': '0.3885', 'rec_cur_loss': '0.3741'} 97 | {'Epoch': 47, 'HIT@1': '0.2064', 'NDCG@1': '0.2064', 'HIT@5': '0.4117', 'NDCG@5': '0.3139', 'HIT@10': '0.5109', 'NDCG@10': '0.3459', 'MRR': '0.3119'} 98 | {'epoch': 48, 'rec_avg_loss': '0.3827', 'rec_cur_loss': '0.3877'} 99 | {'Epoch': 48, 'HIT@1': '0.2062', 'NDCG@1': '0.2062', 'HIT@5': '0.4093', 'NDCG@5': '0.3125', 'HIT@10': '0.5119', 'NDCG@10': '0.3456', 'MRR': '0.3111'} 100 | {'epoch': 49, 'rec_avg_loss': '0.3806', 'rec_cur_loss': '0.3560'} 101 | {'Epoch': 49, 'HIT@1': '0.2047', 'NDCG@1': '0.2047', 'HIT@5': '0.4079', 'NDCG@5': '0.3111', 'HIT@10': '0.5095', 'NDCG@10': '0.3439', 'MRR': '0.3097'} 102 | {'epoch': 50, 'rec_avg_loss': '0.3759', 'rec_cur_loss': '0.3885'} 103 | {'Epoch': 50, 'HIT@1': '0.2042', 'NDCG@1': '0.2042', 'HIT@5': '0.4110', 'NDCG@5': '0.3120', 'HIT@10': '0.5101', 'NDCG@10': '0.3439', 'MRR': '0.3095'} 104 | {'epoch': 51, 'rec_avg_loss': '0.3807', 'rec_cur_loss': '0.3938'} 105 | {'Epoch': 51, 'HIT@1': '0.2039', 'NDCG@1': '0.2039', 'HIT@5': '0.4070', 'NDCG@5': '0.3102', 'HIT@10': '0.5082', 'NDCG@10': '0.3428', 'MRR': '0.3088'} 106 | {'epoch': 52, 'rec_avg_loss': '0.3703', 'rec_cur_loss': '0.3579'} 107 | {'Epoch': 52, 'HIT@1': '0.2036', 'NDCG@1': '0.2036', 'HIT@5': '0.4075', 'NDCG@5': '0.3104', 'HIT@10': '0.5083', 'NDCG@10': '0.3429', 'MRR': '0.3089'} 108 | {'epoch': 53, 'rec_avg_loss': '0.3763', 'rec_cur_loss': '0.3893'} 109 | {'Epoch': 53, 'HIT@1': '0.2043', 'NDCG@1': '0.2043', 'HIT@5': '0.4095', 'NDCG@5': '0.3118', 'HIT@10': '0.5107', 'NDCG@10': '0.3443', 'MRR': '0.3099'} 110 | {'epoch': 54, 'rec_avg_loss': '0.3724', 'rec_cur_loss': '0.3629'} 111 | {'Epoch': 54, 'HIT@1': '0.2062', 'NDCG@1': '0.2062', 'HIT@5': '0.4077', 'NDCG@5': '0.3118', 'HIT@10': '0.5098', 'NDCG@10': '0.3448', 'MRR': '0.3107'} 112 | {'epoch': 55, 'rec_avg_loss': '0.3759', 'rec_cur_loss': '0.3952'} 113 | {'Epoch': 55, 'HIT@1': '0.2070', 'NDCG@1': '0.2070', 'HIT@5': '0.4078', 'NDCG@5': '0.3117', 'HIT@10': '0.5066', 'NDCG@10': '0.3437', 'MRR': '0.3105'} 114 | {'epoch': 56, 'rec_avg_loss': '0.3708', 'rec_cur_loss': '0.3537'} 115 | {'Epoch': 56, 'HIT@1': '0.2048', 'NDCG@1': '0.2048', 'HIT@5': '0.4111', 'NDCG@5': '0.3125', 'HIT@10': '0.5087', 'NDCG@10': '0.3440', 'MRR': '0.3102'} 116 | {'epoch': 57, 'rec_avg_loss': '0.3698', 'rec_cur_loss': '0.3910'} 117 | {'Epoch': 57, 'HIT@1': '0.2055', 'NDCG@1': '0.2055', 'HIT@5': '0.4119', 'NDCG@5': '0.3130', 'HIT@10': '0.5081', 'NDCG@10': '0.3440', 'MRR': '0.3105'} 118 | {'Epoch': 0, 'HIT@1': '0.1775', 'NDCG@1': '0.1775', 'HIT@5': '0.3683', 'NDCG@5': '0.2766', 'HIT@10': '0.4659', 'NDCG@10': '0.3081', 'MRR': '0.2770'} 119 | Finetune_sample-Toys_and_Games-0 120 | {'Epoch': 0, 'HIT@1': '0.1775', 'NDCG@1': '0.1775', 'HIT@5': '0.3683', 'NDCG@5': '0.2766', 'HIT@10': '0.4659', 'NDCG@10': '0.3081', 'MRR': '0.2770'} 121 | -------------------------------------------------------------------------------- /reproduce/Finetune_sample-Toys_and_Games-150.txt: -------------------------------------------------------------------------------- 1 | Namespace(adam_beta1=0.9, adam_beta2=0.999, attention_probs_dropout_prob=0.5, attribute_size=1028, batch_size=256, ckp=150, cuda_condition=True, data_dir='../TOIS/data/', data_file='../TOIS/data/Toys_and_Games.txt', data_name='Toys_and_Games', do_eval=False, epochs=200, gpu_id='0', hidden_act='gelu', hidden_dropout_prob=0.5, hidden_size=64, initializer_range=0.02, item_size=11926, log_file='output/Finetune_sample-Toys_and_Games-150.txt', log_freq=1, lr=0.001, mask_id=11925, max_seq_length=50, model_name='Finetune_sample', no_cuda=False, num_attention_heads=2, num_hidden_layers=2, output_dir='output/', sample_file='../TOIS/data/Toys_and_Games_sample.txt', seed=42, weight_decay=0.0) 2 | {'epoch': 0, 'rec_avg_loss': '1.0338', 'rec_cur_loss': '0.9243'} 3 | {'Epoch': 0, 'HIT@1': '0.1605', 'NDCG@1': '0.1605', 'HIT@5': '0.3940', 'NDCG@5': '0.2808', 'HIT@10': '0.5260', 'NDCG@10': '0.3235', 'MRR': '0.2792'} 4 | {'epoch': 1, 'rec_avg_loss': '0.9103', 'rec_cur_loss': '0.8343'} 5 | {'Epoch': 1, 'HIT@1': '0.1772', 'NDCG@1': '0.1772', 'HIT@5': '0.4226', 'NDCG@5': '0.3043', 'HIT@10': '0.5522', 'NDCG@10': '0.3462', 'MRR': '0.2996'} 6 | {'epoch': 2, 'rec_avg_loss': '0.8637', 'rec_cur_loss': '0.8427'} 7 | {'Epoch': 2, 'HIT@1': '0.1826', 'NDCG@1': '0.1826', 'HIT@5': '0.4314', 'NDCG@5': '0.3118', 'HIT@10': '0.5623', 'NDCG@10': '0.3541', 'MRR': '0.3065'} 8 | {'epoch': 3, 'rec_avg_loss': '0.8337', 'rec_cur_loss': '0.8616'} 9 | {'Epoch': 3, 'HIT@1': '0.1853', 'NDCG@1': '0.1853', 'HIT@5': '0.4392', 'NDCG@5': '0.3171', 'HIT@10': '0.5673', 'NDCG@10': '0.3587', 'MRR': '0.3107'} 10 | {'epoch': 4, 'rec_avg_loss': '0.8110', 'rec_cur_loss': '0.7723'} 11 | {'Epoch': 4, 'HIT@1': '0.1912', 'NDCG@1': '0.1912', 'HIT@5': '0.4448', 'NDCG@5': '0.3229', 'HIT@10': '0.5712', 'NDCG@10': '0.3638', 'MRR': '0.3160'} 12 | {'epoch': 5, 'rec_avg_loss': '0.7974', 'rec_cur_loss': '0.7897'} 13 | {'Epoch': 5, 'HIT@1': '0.1926', 'NDCG@1': '0.1926', 'HIT@5': '0.4479', 'NDCG@5': '0.3253', 'HIT@10': '0.5729', 'NDCG@10': '0.3658', 'MRR': '0.3179'} 14 | {'epoch': 6, 'rec_avg_loss': '0.7830', 'rec_cur_loss': '0.7485'} 15 | {'Epoch': 6, 'HIT@1': '0.1935', 'NDCG@1': '0.1935', 'HIT@5': '0.4514', 'NDCG@5': '0.3278', 'HIT@10': '0.5773', 'NDCG@10': '0.3686', 'MRR': '0.3200'} 16 | {'epoch': 7, 'rec_avg_loss': '0.7781', 'rec_cur_loss': '0.8233'} 17 | {'Epoch': 7, 'HIT@1': '0.1981', 'NDCG@1': '0.1981', 'HIT@5': '0.4546', 'NDCG@5': '0.3316', 'HIT@10': '0.5790', 'NDCG@10': '0.3719', 'MRR': '0.3238'} 18 | {'epoch': 8, 'rec_avg_loss': '0.7641', 'rec_cur_loss': '0.7385'} 19 | {'Epoch': 8, 'HIT@1': '0.1971', 'NDCG@1': '0.1971', 'HIT@5': '0.4549', 'NDCG@5': '0.3307', 'HIT@10': '0.5808', 'NDCG@10': '0.3715', 'MRR': '0.3225'} 20 | {'epoch': 9, 'rec_avg_loss': '0.7566', 'rec_cur_loss': '0.7865'} 21 | {'Epoch': 9, 'HIT@1': '0.2018', 'NDCG@1': '0.2018', 'HIT@5': '0.4594', 'NDCG@5': '0.3359', 'HIT@10': '0.5831', 'NDCG@10': '0.3759', 'MRR': '0.3276'} 22 | {'epoch': 10, 'rec_avg_loss': '0.7454', 'rec_cur_loss': '0.7902'} 23 | {'Epoch': 10, 'HIT@1': '0.2051', 'NDCG@1': '0.2051', 'HIT@5': '0.4601', 'NDCG@5': '0.3379', 'HIT@10': '0.5838', 'NDCG@10': '0.3778', 'MRR': '0.3298'} 24 | {'epoch': 11, 'rec_avg_loss': '0.7374', 'rec_cur_loss': '0.7819'} 25 | {'Epoch': 11, 'HIT@1': '0.2065', 'NDCG@1': '0.2065', 'HIT@5': '0.4624', 'NDCG@5': '0.3397', 'HIT@10': '0.5849', 'NDCG@10': '0.3793', 'MRR': '0.3314'} 26 | {'epoch': 12, 'rec_avg_loss': '0.7339', 'rec_cur_loss': '0.8055'} 27 | {'Epoch': 12, 'HIT@1': '0.2091', 'NDCG@1': '0.2091', 'HIT@5': '0.4648', 'NDCG@5': '0.3422', 'HIT@10': '0.5862', 'NDCG@10': '0.3815', 'MRR': '0.3338'} 28 | {'epoch': 13, 'rec_avg_loss': '0.7209', 'rec_cur_loss': '0.6906'} 29 | {'Epoch': 13, 'HIT@1': '0.2082', 'NDCG@1': '0.2082', 'HIT@5': '0.4661', 'NDCG@5': '0.3425', 'HIT@10': '0.5862', 'NDCG@10': '0.3814', 'MRR': '0.3336'} 30 | {'epoch': 14, 'rec_avg_loss': '0.7192', 'rec_cur_loss': '0.6677'} 31 | {'Epoch': 14, 'HIT@1': '0.2130', 'NDCG@1': '0.2130', 'HIT@5': '0.4703', 'NDCG@5': '0.3469', 'HIT@10': '0.5895', 'NDCG@10': '0.3855', 'MRR': '0.3377'} 32 | {'epoch': 15, 'rec_avg_loss': '0.7128', 'rec_cur_loss': '0.7208'} 33 | {'Epoch': 15, 'HIT@1': '0.2119', 'NDCG@1': '0.2119', 'HIT@5': '0.4703', 'NDCG@5': '0.3467', 'HIT@10': '0.5864', 'NDCG@10': '0.3844', 'MRR': '0.3373'} 34 | {'epoch': 16, 'rec_avg_loss': '0.7024', 'rec_cur_loss': '0.7226'} 35 | {'Epoch': 16, 'HIT@1': '0.2114', 'NDCG@1': '0.2114', 'HIT@5': '0.4711', 'NDCG@5': '0.3466', 'HIT@10': '0.5892', 'NDCG@10': '0.3847', 'MRR': '0.3369'} 36 | {'epoch': 17, 'rec_avg_loss': '0.6951', 'rec_cur_loss': '0.7395'} 37 | {'Epoch': 17, 'HIT@1': '0.2145', 'NDCG@1': '0.2145', 'HIT@5': '0.4724', 'NDCG@5': '0.3493', 'HIT@10': '0.5901', 'NDCG@10': '0.3874', 'MRR': '0.3400'} 38 | {'epoch': 18, 'rec_avg_loss': '0.6911', 'rec_cur_loss': '0.7279'} 39 | {'Epoch': 18, 'HIT@1': '0.2172', 'NDCG@1': '0.2172', 'HIT@5': '0.4739', 'NDCG@5': '0.3516', 'HIT@10': '0.5900', 'NDCG@10': '0.3892', 'MRR': '0.3424'} 40 | {'epoch': 19, 'rec_avg_loss': '0.6865', 'rec_cur_loss': '0.6828'} 41 | {'Epoch': 19, 'HIT@1': '0.2192', 'NDCG@1': '0.2192', 'HIT@5': '0.4749', 'NDCG@5': '0.3527', 'HIT@10': '0.5933', 'NDCG@10': '0.3910', 'MRR': '0.3435'} 42 | {'epoch': 20, 'rec_avg_loss': '0.6825', 'rec_cur_loss': '0.7113'} 43 | {'Epoch': 20, 'HIT@1': '0.2157', 'NDCG@1': '0.2157', 'HIT@5': '0.4731', 'NDCG@5': '0.3503', 'HIT@10': '0.5919', 'NDCG@10': '0.3888', 'MRR': '0.3413'} 44 | {'epoch': 21, 'rec_avg_loss': '0.6743', 'rec_cur_loss': '0.6834'} 45 | {'Epoch': 21, 'HIT@1': '0.2199', 'NDCG@1': '0.2199', 'HIT@5': '0.4749', 'NDCG@5': '0.3528', 'HIT@10': '0.5928', 'NDCG@10': '0.3910', 'MRR': '0.3439'} 46 | {'epoch': 22, 'rec_avg_loss': '0.6730', 'rec_cur_loss': '0.6481'} 47 | {'Epoch': 22, 'HIT@1': '0.2196', 'NDCG@1': '0.2196', 'HIT@5': '0.4745', 'NDCG@5': '0.3525', 'HIT@10': '0.5925', 'NDCG@10': '0.3908', 'MRR': '0.3436'} 48 | {'epoch': 23, 'rec_avg_loss': '0.6652', 'rec_cur_loss': '0.7123'} 49 | {'Epoch': 23, 'HIT@1': '0.2201', 'NDCG@1': '0.2201', 'HIT@5': '0.4760', 'NDCG@5': '0.3540', 'HIT@10': '0.5917', 'NDCG@10': '0.3915', 'MRR': '0.3448'} 50 | {'epoch': 24, 'rec_avg_loss': '0.6619', 'rec_cur_loss': '0.6178'} 51 | {'Epoch': 24, 'HIT@1': '0.2227', 'NDCG@1': '0.2227', 'HIT@5': '0.4752', 'NDCG@5': '0.3545', 'HIT@10': '0.5948', 'NDCG@10': '0.3933', 'MRR': '0.3461'} 52 | {'epoch': 25, 'rec_avg_loss': '0.6538', 'rec_cur_loss': '0.6708'} 53 | {'Epoch': 25, 'HIT@1': '0.2222', 'NDCG@1': '0.2222', 'HIT@5': '0.4801', 'NDCG@5': '0.3568', 'HIT@10': '0.5942', 'NDCG@10': '0.3938', 'MRR': '0.3469'} 54 | {'epoch': 26, 'rec_avg_loss': '0.6495', 'rec_cur_loss': '0.5758'} 55 | {'Epoch': 26, 'HIT@1': '0.2231', 'NDCG@1': '0.2231', 'HIT@5': '0.4770', 'NDCG@5': '0.3558', 'HIT@10': '0.5928', 'NDCG@10': '0.3934', 'MRR': '0.3470'} 56 | {'epoch': 27, 'rec_avg_loss': '0.6485', 'rec_cur_loss': '0.6236'} 57 | {'Epoch': 27, 'HIT@1': '0.2240', 'NDCG@1': '0.2240', 'HIT@5': '0.4794', 'NDCG@5': '0.3577', 'HIT@10': '0.5946', 'NDCG@10': '0.3951', 'MRR': '0.3484'} 58 | {'epoch': 28, 'rec_avg_loss': '0.6428', 'rec_cur_loss': '0.6506'} 59 | {'Epoch': 28, 'HIT@1': '0.2248', 'NDCG@1': '0.2248', 'HIT@5': '0.4800', 'NDCG@5': '0.3584', 'HIT@10': '0.5942', 'NDCG@10': '0.3954', 'MRR': '0.3491'} 60 | {'epoch': 29, 'rec_avg_loss': '0.6372', 'rec_cur_loss': '0.6632'} 61 | {'Epoch': 29, 'HIT@1': '0.2256', 'NDCG@1': '0.2256', 'HIT@5': '0.4803', 'NDCG@5': '0.3582', 'HIT@10': '0.5952', 'NDCG@10': '0.3955', 'MRR': '0.3488'} 62 | {'epoch': 30, 'rec_avg_loss': '0.6397', 'rec_cur_loss': '0.6943'} 63 | {'Epoch': 30, 'HIT@1': '0.2264', 'NDCG@1': '0.2264', 'HIT@5': '0.4804', 'NDCG@5': '0.3592', 'HIT@10': '0.5944', 'NDCG@10': '0.3961', 'MRR': '0.3500'} 64 | {'epoch': 31, 'rec_avg_loss': '0.6302', 'rec_cur_loss': '0.6513'} 65 | {'Epoch': 31, 'HIT@1': '0.2282', 'NDCG@1': '0.2282', 'HIT@5': '0.4827', 'NDCG@5': '0.3611', 'HIT@10': '0.5980', 'NDCG@10': '0.3983', 'MRR': '0.3515'} 66 | {'epoch': 32, 'rec_avg_loss': '0.6267', 'rec_cur_loss': '0.6309'} 67 | {'Epoch': 32, 'HIT@1': '0.2272', 'NDCG@1': '0.2272', 'HIT@5': '0.4799', 'NDCG@5': '0.3591', 'HIT@10': '0.5967', 'NDCG@10': '0.3970', 'MRR': '0.3502'} 68 | {'epoch': 33, 'rec_avg_loss': '0.6219', 'rec_cur_loss': '0.6334'} 69 | {'Epoch': 33, 'HIT@1': '0.2270', 'NDCG@1': '0.2270', 'HIT@5': '0.4809', 'NDCG@5': '0.3597', 'HIT@10': '0.5968', 'NDCG@10': '0.3971', 'MRR': '0.3504'} 70 | {'epoch': 34, 'rec_avg_loss': '0.6218', 'rec_cur_loss': '0.6180'} 71 | {'Epoch': 34, 'HIT@1': '0.2266', 'NDCG@1': '0.2266', 'HIT@5': '0.4798', 'NDCG@5': '0.3593', 'HIT@10': '0.5970', 'NDCG@10': '0.3973', 'MRR': '0.3506'} 72 | {'epoch': 35, 'rec_avg_loss': '0.6171', 'rec_cur_loss': '0.5776'} 73 | {'Epoch': 35, 'HIT@1': '0.2298', 'NDCG@1': '0.2298', 'HIT@5': '0.4833', 'NDCG@5': '0.3625', 'HIT@10': '0.5981', 'NDCG@10': '0.3996', 'MRR': '0.3531'} 74 | {'epoch': 36, 'rec_avg_loss': '0.6129', 'rec_cur_loss': '0.6242'} 75 | {'Epoch': 36, 'HIT@1': '0.2296', 'NDCG@1': '0.2296', 'HIT@5': '0.4817', 'NDCG@5': '0.3613', 'HIT@10': '0.5965', 'NDCG@10': '0.3985', 'MRR': '0.3523'} 76 | {'epoch': 37, 'rec_avg_loss': '0.6082', 'rec_cur_loss': '0.6366'} 77 | {'Epoch': 37, 'HIT@1': '0.2288', 'NDCG@1': '0.2288', 'HIT@5': '0.4815', 'NDCG@5': '0.3609', 'HIT@10': '0.5981', 'NDCG@10': '0.3987', 'MRR': '0.3520'} 78 | {'epoch': 38, 'rec_avg_loss': '0.6073', 'rec_cur_loss': '0.5802'} 79 | {'Epoch': 38, 'HIT@1': '0.2323', 'NDCG@1': '0.2323', 'HIT@5': '0.4811', 'NDCG@5': '0.3624', 'HIT@10': '0.5980', 'NDCG@10': '0.4003', 'MRR': '0.3542'} 80 | {'epoch': 39, 'rec_avg_loss': '0.5995', 'rec_cur_loss': '0.5936'} 81 | {'Epoch': 39, 'HIT@1': '0.2294', 'NDCG@1': '0.2294', 'HIT@5': '0.4792', 'NDCG@5': '0.3605', 'HIT@10': '0.5983', 'NDCG@10': '0.3991', 'MRR': '0.3524'} 82 | {'epoch': 40, 'rec_avg_loss': '0.6007', 'rec_cur_loss': '0.6319'} 83 | {'Epoch': 40, 'HIT@1': '0.2304', 'NDCG@1': '0.2304', 'HIT@5': '0.4832', 'NDCG@5': '0.3627', 'HIT@10': '0.5979', 'NDCG@10': '0.3998', 'MRR': '0.3535'} 84 | {'epoch': 41, 'rec_avg_loss': '0.5951', 'rec_cur_loss': '0.5907'} 85 | {'Epoch': 41, 'HIT@1': '0.2288', 'NDCG@1': '0.2288', 'HIT@5': '0.4825', 'NDCG@5': '0.3620', 'HIT@10': '0.5987', 'NDCG@10': '0.3996', 'MRR': '0.3529'} 86 | {'epoch': 42, 'rec_avg_loss': '0.5910', 'rec_cur_loss': '0.5619'} 87 | {'Epoch': 42, 'HIT@1': '0.2297', 'NDCG@1': '0.2297', 'HIT@5': '0.4841', 'NDCG@5': '0.3632', 'HIT@10': '0.5977', 'NDCG@10': '0.4000', 'MRR': '0.3537'} 88 | {'epoch': 43, 'rec_avg_loss': '0.5908', 'rec_cur_loss': '0.6076'} 89 | {'Epoch': 43, 'HIT@1': '0.2326', 'NDCG@1': '0.2326', 'HIT@5': '0.4836', 'NDCG@5': '0.3643', 'HIT@10': '0.5980', 'NDCG@10': '0.4013', 'MRR': '0.3553'} 90 | {'epoch': 44, 'rec_avg_loss': '0.5830', 'rec_cur_loss': '0.5649'} 91 | {'Epoch': 44, 'HIT@1': '0.2331', 'NDCG@1': '0.2331', 'HIT@5': '0.4838', 'NDCG@5': '0.3643', 'HIT@10': '0.5977', 'NDCG@10': '0.4013', 'MRR': '0.3554'} 92 | {'epoch': 45, 'rec_avg_loss': '0.5831', 'rec_cur_loss': '0.5935'} 93 | {'Epoch': 45, 'HIT@1': '0.2321', 'NDCG@1': '0.2321', 'HIT@5': '0.4845', 'NDCG@5': '0.3643', 'HIT@10': '0.5965', 'NDCG@10': '0.4006', 'MRR': '0.3550'} 94 | {'epoch': 46, 'rec_avg_loss': '0.5811', 'rec_cur_loss': '0.5642'} 95 | {'Epoch': 46, 'HIT@1': '0.2318', 'NDCG@1': '0.2318', 'HIT@5': '0.4845', 'NDCG@5': '0.3642', 'HIT@10': '0.5960', 'NDCG@10': '0.4003', 'MRR': '0.3548'} 96 | {'epoch': 47, 'rec_avg_loss': '0.5753', 'rec_cur_loss': '0.5557'} 97 | {'Epoch': 47, 'HIT@1': '0.2345', 'NDCG@1': '0.2345', 'HIT@5': '0.4859', 'NDCG@5': '0.3665', 'HIT@10': '0.5964', 'NDCG@10': '0.4023', 'MRR': '0.3572'} 98 | {'epoch': 48, 'rec_avg_loss': '0.5688', 'rec_cur_loss': '0.5721'} 99 | {'Epoch': 48, 'HIT@1': '0.2336', 'NDCG@1': '0.2336', 'HIT@5': '0.4860', 'NDCG@5': '0.3659', 'HIT@10': '0.5984', 'NDCG@10': '0.4023', 'MRR': '0.3564'} 100 | {'epoch': 49, 'rec_avg_loss': '0.5691', 'rec_cur_loss': '0.5494'} 101 | {'Epoch': 49, 'HIT@1': '0.2366', 'NDCG@1': '0.2366', 'HIT@5': '0.4855', 'NDCG@5': '0.3671', 'HIT@10': '0.5963', 'NDCG@10': '0.4030', 'MRR': '0.3581'} 102 | {'epoch': 50, 'rec_avg_loss': '0.5668', 'rec_cur_loss': '0.5928'} 103 | {'Epoch': 50, 'HIT@1': '0.2351', 'NDCG@1': '0.2351', 'HIT@5': '0.4851', 'NDCG@5': '0.3662', 'HIT@10': '0.5972', 'NDCG@10': '0.4025', 'MRR': '0.3572'} 104 | {'epoch': 51, 'rec_avg_loss': '0.5674', 'rec_cur_loss': '0.5616'} 105 | {'Epoch': 51, 'HIT@1': '0.2360', 'NDCG@1': '0.2360', 'HIT@5': '0.4861', 'NDCG@5': '0.3672', 'HIT@10': '0.5977', 'NDCG@10': '0.4032', 'MRR': '0.3580'} 106 | {'epoch': 52, 'rec_avg_loss': '0.5594', 'rec_cur_loss': '0.5098'} 107 | {'Epoch': 52, 'HIT@1': '0.2363', 'NDCG@1': '0.2363', 'HIT@5': '0.4884', 'NDCG@5': '0.3685', 'HIT@10': '0.5984', 'NDCG@10': '0.4041', 'MRR': '0.3587'} 108 | {'epoch': 53, 'rec_avg_loss': '0.5570', 'rec_cur_loss': '0.5401'} 109 | {'Epoch': 53, 'HIT@1': '0.2345', 'NDCG@1': '0.2345', 'HIT@5': '0.4869', 'NDCG@5': '0.3668', 'HIT@10': '0.5957', 'NDCG@10': '0.4021', 'MRR': '0.3571'} 110 | {'epoch': 54, 'rec_avg_loss': '0.5571', 'rec_cur_loss': '0.5535'} 111 | {'Epoch': 54, 'HIT@1': '0.2360', 'NDCG@1': '0.2360', 'HIT@5': '0.4871', 'NDCG@5': '0.3682', 'HIT@10': '0.5973', 'NDCG@10': '0.4038', 'MRR': '0.3587'} 112 | {'epoch': 55, 'rec_avg_loss': '0.5556', 'rec_cur_loss': '0.5546'} 113 | {'Epoch': 55, 'HIT@1': '0.2374', 'NDCG@1': '0.2374', 'HIT@5': '0.4855', 'NDCG@5': '0.3678', 'HIT@10': '0.5968', 'NDCG@10': '0.4037', 'MRR': '0.3590'} 114 | {'epoch': 56, 'rec_avg_loss': '0.5554', 'rec_cur_loss': '0.5389'} 115 | {'Epoch': 56, 'HIT@1': '0.2374', 'NDCG@1': '0.2374', 'HIT@5': '0.4867', 'NDCG@5': '0.3683', 'HIT@10': '0.5979', 'NDCG@10': '0.4042', 'MRR': '0.3591'} 116 | {'epoch': 57, 'rec_avg_loss': '0.5542', 'rec_cur_loss': '0.5537'} 117 | {'Epoch': 57, 'HIT@1': '0.2355', 'NDCG@1': '0.2355', 'HIT@5': '0.4870', 'NDCG@5': '0.3675', 'HIT@10': '0.5961', 'NDCG@10': '0.4028', 'MRR': '0.3579'} 118 | {'epoch': 58, 'rec_avg_loss': '0.5478', 'rec_cur_loss': '0.5617'} 119 | {'Epoch': 58, 'HIT@1': '0.2368', 'NDCG@1': '0.2368', 'HIT@5': '0.4857', 'NDCG@5': '0.3678', 'HIT@10': '0.5959', 'NDCG@10': '0.4033', 'MRR': '0.3587'} 120 | {'epoch': 59, 'rec_avg_loss': '0.5425', 'rec_cur_loss': '0.5756'} 121 | {'Epoch': 59, 'HIT@1': '0.2346', 'NDCG@1': '0.2346', 'HIT@5': '0.4836', 'NDCG@5': '0.3655', 'HIT@10': '0.5963', 'NDCG@10': '0.4019', 'MRR': '0.3568'} 122 | {'epoch': 60, 'rec_avg_loss': '0.5456', 'rec_cur_loss': '0.5455'} 123 | {'Epoch': 60, 'HIT@1': '0.2395', 'NDCG@1': '0.2395', 'HIT@5': '0.4850', 'NDCG@5': '0.3686', 'HIT@10': '0.5951', 'NDCG@10': '0.4042', 'MRR': '0.3602'} 124 | {'epoch': 61, 'rec_avg_loss': '0.5388', 'rec_cur_loss': '0.5352'} 125 | {'Epoch': 61, 'HIT@1': '0.2373', 'NDCG@1': '0.2373', 'HIT@5': '0.4831', 'NDCG@5': '0.3666', 'HIT@10': '0.5936', 'NDCG@10': '0.4023', 'MRR': '0.3582'} 126 | {'epoch': 62, 'rec_avg_loss': '0.5364', 'rec_cur_loss': '0.5431'} 127 | {'Epoch': 62, 'HIT@1': '0.2399', 'NDCG@1': '0.2399', 'HIT@5': '0.4849', 'NDCG@5': '0.3686', 'HIT@10': '0.5931', 'NDCG@10': '0.4037', 'MRR': '0.3603'} 128 | {'epoch': 63, 'rec_avg_loss': '0.5339', 'rec_cur_loss': '0.5041'} 129 | {'Epoch': 63, 'HIT@1': '0.2361', 'NDCG@1': '0.2361', 'HIT@5': '0.4862', 'NDCG@5': '0.3675', 'HIT@10': '0.5936', 'NDCG@10': '0.4022', 'MRR': '0.3580'} 130 | {'epoch': 64, 'rec_avg_loss': '0.5322', 'rec_cur_loss': '0.5552'} 131 | {'Epoch': 64, 'HIT@1': '0.2358', 'NDCG@1': '0.2358', 'HIT@5': '0.4829', 'NDCG@5': '0.3659', 'HIT@10': '0.5943', 'NDCG@10': '0.4020', 'MRR': '0.3575'} 132 | {'epoch': 65, 'rec_avg_loss': '0.5287', 'rec_cur_loss': '0.5000'} 133 | {'Epoch': 65, 'HIT@1': '0.2379', 'NDCG@1': '0.2379', 'HIT@5': '0.4848', 'NDCG@5': '0.3676', 'HIT@10': '0.5950', 'NDCG@10': '0.4033', 'MRR': '0.3590'} 134 | {'epoch': 66, 'rec_avg_loss': '0.5257', 'rec_cur_loss': '0.4785'} 135 | {'Epoch': 66, 'HIT@1': '0.2393', 'NDCG@1': '0.2393', 'HIT@5': '0.4866', 'NDCG@5': '0.3695', 'HIT@10': '0.5932', 'NDCG@10': '0.4041', 'MRR': '0.3606'} 136 | {'epoch': 67, 'rec_avg_loss': '0.5242', 'rec_cur_loss': '0.5187'} 137 | {'Epoch': 67, 'HIT@1': '0.2365', 'NDCG@1': '0.2365', 'HIT@5': '0.4836', 'NDCG@5': '0.3670', 'HIT@10': '0.5946', 'NDCG@10': '0.4029', 'MRR': '0.3586'} 138 | {'epoch': 68, 'rec_avg_loss': '0.5231', 'rec_cur_loss': '0.5074'} 139 | {'Epoch': 68, 'HIT@1': '0.2382', 'NDCG@1': '0.2382', 'HIT@5': '0.4836', 'NDCG@5': '0.3677', 'HIT@10': '0.5930', 'NDCG@10': '0.4032', 'MRR': '0.3595'} 140 | {'epoch': 69, 'rec_avg_loss': '0.5209', 'rec_cur_loss': '0.5244'} 141 | {'Epoch': 69, 'HIT@1': '0.2379', 'NDCG@1': '0.2379', 'HIT@5': '0.4866', 'NDCG@5': '0.3685', 'HIT@10': '0.5937', 'NDCG@10': '0.4032', 'MRR': '0.3593'} 142 | {'epoch': 70, 'rec_avg_loss': '0.5180', 'rec_cur_loss': '0.5193'} 143 | {'Epoch': 70, 'HIT@1': '0.2388', 'NDCG@1': '0.2388', 'HIT@5': '0.4851', 'NDCG@5': '0.3685', 'HIT@10': '0.5950', 'NDCG@10': '0.4040', 'MRR': '0.3598'} 144 | {'epoch': 71, 'rec_avg_loss': '0.5158', 'rec_cur_loss': '0.5191'} 145 | {'Epoch': 71, 'HIT@1': '0.2374', 'NDCG@1': '0.2374', 'HIT@5': '0.4831', 'NDCG@5': '0.3664', 'HIT@10': '0.5932', 'NDCG@10': '0.4020', 'MRR': '0.3579'} 146 | {'epoch': 72, 'rec_avg_loss': '0.5138', 'rec_cur_loss': '0.5274'} 147 | {'Epoch': 72, 'HIT@1': '0.2363', 'NDCG@1': '0.2363', 'HIT@5': '0.4832', 'NDCG@5': '0.3664', 'HIT@10': '0.5918', 'NDCG@10': '0.4015', 'MRR': '0.3576'} 148 | {'epoch': 73, 'rec_avg_loss': '0.5123', 'rec_cur_loss': '0.4933'} 149 | {'Epoch': 73, 'HIT@1': '0.2366', 'NDCG@1': '0.2366', 'HIT@5': '0.4845', 'NDCG@5': '0.3670', 'HIT@10': '0.5935', 'NDCG@10': '0.4022', 'MRR': '0.3580'} 150 | {'epoch': 74, 'rec_avg_loss': '0.5087', 'rec_cur_loss': '0.4798'} 151 | {'Epoch': 74, 'HIT@1': '0.2377', 'NDCG@1': '0.2377', 'HIT@5': '0.4816', 'NDCG@5': '0.3659', 'HIT@10': '0.5914', 'NDCG@10': '0.4015', 'MRR': '0.3579'} 152 | {'epoch': 75, 'rec_avg_loss': '0.5075', 'rec_cur_loss': '0.5129'} 153 | {'Epoch': 75, 'HIT@1': '0.2379', 'NDCG@1': '0.2379', 'HIT@5': '0.4855', 'NDCG@5': '0.3679', 'HIT@10': '0.5932', 'NDCG@10': '0.4026', 'MRR': '0.3586'} 154 | {'epoch': 76, 'rec_avg_loss': '0.5065', 'rec_cur_loss': '0.5119'} 155 | {'Epoch': 76, 'HIT@1': '0.2370', 'NDCG@1': '0.2370', 'HIT@5': '0.4809', 'NDCG@5': '0.3659', 'HIT@10': '0.5912', 'NDCG@10': '0.4015', 'MRR': '0.3580'} 156 | {'Epoch': 0, 'HIT@1': '0.2070', 'NDCG@1': '0.2070', 'HIT@5': '0.4481', 'NDCG@5': '0.3335', 'HIT@10': '0.5593', 'NDCG@10': '0.3695', 'MRR': '0.3268'} 157 | Finetune_sample-Toys_and_Games-150 158 | {'Epoch': 0, 'HIT@1': '0.2070', 'NDCG@1': '0.2070', 'HIT@5': '0.4481', 'NDCG@5': '0.3335', 'HIT@10': '0.5593', 'NDCG@10': '0.3695', 'MRR': '0.3268'} 159 | -------------------------------------------------------------------------------- /reproduce/Finetune_sample-Yelp-0.txt: -------------------------------------------------------------------------------- 1 | Namespace(adam_beta1=0.9, adam_beta2=0.999, attention_probs_dropout_prob=0.5, attribute_size=1002, batch_size=256, ckp=0, cuda_condition=True, data_dir='../TOIS/data/', data_file='../TOIS/data/Yelp.txt', data_name='Yelp', do_eval=False, epochs=200, gpu_id='2', hidden_act='gelu', hidden_dropout_prob=0.5, hidden_size=64, initializer_range=0.02, item_size=20035, log_file='output/Finetune_sample-Yelp-0.txt', log_freq=1, lr=0.001, mask_id=20034, max_seq_length=50, model_name='Finetune_sample', no_cuda=False, num_attention_heads=2, num_hidden_layers=2, output_dir='output/', sample_file='../TOIS/data/Yelp_sample.txt', seed=42, weight_decay=0.0) 2 | {'epoch': 0, 'rec_avg_loss': '1.3383', 'rec_cur_loss': '1.2466'} 3 | {'Epoch': 0, 'HIT@1': '0.0762', 'NDCG@1': '0.0762', 'HIT@5': '0.2278', 'NDCG@5': '0.1528', 'HIT@10': '0.3384', 'NDCG@10': '0.1884', 'MRR': '0.1642'} 4 | {'epoch': 1, 'rec_avg_loss': '1.2235', 'rec_cur_loss': '1.2007'} 5 | {'Epoch': 1, 'HIT@1': '0.0817', 'NDCG@1': '0.0817', 'HIT@5': '0.2439', 'NDCG@5': '0.1636', 'HIT@10': '0.3635', 'NDCG@10': '0.2021', 'MRR': '0.1745'} 6 | {'epoch': 2, 'rec_avg_loss': '1.1393', 'rec_cur_loss': '1.0790'} 7 | {'Epoch': 2, 'HIT@1': '0.1102', 'NDCG@1': '0.1102', 'HIT@5': '0.3163', 'NDCG@5': '0.2150', 'HIT@10': '0.4597', 'NDCG@10': '0.2613', 'MRR': '0.2225'} 8 | {'epoch': 3, 'rec_avg_loss': '1.0075', 'rec_cur_loss': '0.9830'} 9 | {'Epoch': 3, 'HIT@1': '0.1385', 'NDCG@1': '0.1385', 'HIT@5': '0.3826', 'NDCG@5': '0.2628', 'HIT@10': '0.5329', 'NDCG@10': '0.3112', 'MRR': '0.2637'} 10 | {'epoch': 4, 'rec_avg_loss': '0.8882', 'rec_cur_loss': '0.8453'} 11 | {'Epoch': 4, 'HIT@1': '0.1651', 'NDCG@1': '0.1651', 'HIT@5': '0.4500', 'NDCG@5': '0.3104', 'HIT@10': '0.6256', 'NDCG@10': '0.3670', 'MRR': '0.3063'} 12 | {'epoch': 5, 'rec_avg_loss': '0.7745', 'rec_cur_loss': '0.7649'} 13 | {'Epoch': 5, 'HIT@1': '0.1712', 'NDCG@1': '0.1712', 'HIT@5': '0.4685', 'NDCG@5': '0.3232', 'HIT@10': '0.6541', 'NDCG@10': '0.3832', 'MRR': '0.3185'} 14 | {'epoch': 6, 'rec_avg_loss': '0.6984', 'rec_cur_loss': '0.6961'} 15 | {'Epoch': 6, 'HIT@1': '0.1792', 'NDCG@1': '0.1792', 'HIT@5': '0.4848', 'NDCG@5': '0.3353', 'HIT@10': '0.6723', 'NDCG@10': '0.3959', 'MRR': '0.3291'} 16 | {'epoch': 7, 'rec_avg_loss': '0.6419', 'rec_cur_loss': '0.6452'} 17 | {'Epoch': 7, 'HIT@1': '0.1899', 'NDCG@1': '0.1899', 'HIT@5': '0.5051', 'NDCG@5': '0.3514', 'HIT@10': '0.6911', 'NDCG@10': '0.4114', 'MRR': '0.3425'} 18 | {'epoch': 8, 'rec_avg_loss': '0.6040', 'rec_cur_loss': '0.6046'} 19 | {'Epoch': 8, 'HIT@1': '0.2001', 'NDCG@1': '0.2001', 'HIT@5': '0.5180', 'NDCG@5': '0.3630', 'HIT@10': '0.7051', 'NDCG@10': '0.4235', 'MRR': '0.3532'} 20 | {'epoch': 9, 'rec_avg_loss': '0.5749', 'rec_cur_loss': '0.5912'} 21 | {'Epoch': 9, 'HIT@1': '0.2084', 'NDCG@1': '0.2084', 'HIT@5': '0.5306', 'NDCG@5': '0.3737', 'HIT@10': '0.7157', 'NDCG@10': '0.4337', 'MRR': '0.3627'} 22 | {'epoch': 10, 'rec_avg_loss': '0.5438', 'rec_cur_loss': '0.5652'} 23 | {'Epoch': 10, 'HIT@1': '0.2105', 'NDCG@1': '0.2105', 'HIT@5': '0.5380', 'NDCG@5': '0.3782', 'HIT@10': '0.7226', 'NDCG@10': '0.4379', 'MRR': '0.3657'} 24 | {'epoch': 11, 'rec_avg_loss': '0.5270', 'rec_cur_loss': '0.5518'} 25 | {'Epoch': 11, 'HIT@1': '0.2145', 'NDCG@1': '0.2145', 'HIT@5': '0.5450', 'NDCG@5': '0.3839', 'HIT@10': '0.7287', 'NDCG@10': '0.4433', 'MRR': '0.3706'} 26 | {'epoch': 12, 'rec_avg_loss': '0.5074', 'rec_cur_loss': '0.5009'} 27 | {'Epoch': 12, 'HIT@1': '0.2153', 'NDCG@1': '0.2153', 'HIT@5': '0.5511', 'NDCG@5': '0.3875', 'HIT@10': '0.7320', 'NDCG@10': '0.4461', 'MRR': '0.3728'} 28 | {'epoch': 13, 'rec_avg_loss': '0.4924', 'rec_cur_loss': '0.5223'} 29 | {'Epoch': 13, 'HIT@1': '0.2157', 'NDCG@1': '0.2157', 'HIT@5': '0.5520', 'NDCG@5': '0.3878', 'HIT@10': '0.7333', 'NDCG@10': '0.4465', 'MRR': '0.3730'} 30 | {'epoch': 14, 'rec_avg_loss': '0.4812', 'rec_cur_loss': '0.4955'} 31 | {'Epoch': 14, 'HIT@1': '0.2222', 'NDCG@1': '0.2222', 'HIT@5': '0.5555', 'NDCG@5': '0.3935', 'HIT@10': '0.7349', 'NDCG@10': '0.4517', 'MRR': '0.3791'} 32 | {'epoch': 15, 'rec_avg_loss': '0.4653', 'rec_cur_loss': '0.4767'} 33 | {'Epoch': 15, 'HIT@1': '0.2248', 'NDCG@1': '0.2248', 'HIT@5': '0.5586', 'NDCG@5': '0.3964', 'HIT@10': '0.7390', 'NDCG@10': '0.4549', 'MRR': '0.3818'} 34 | {'epoch': 16, 'rec_avg_loss': '0.4599', 'rec_cur_loss': '0.4803'} 35 | {'Epoch': 16, 'HIT@1': '0.2228', 'NDCG@1': '0.2228', 'HIT@5': '0.5600', 'NDCG@5': '0.3960', 'HIT@10': '0.7391', 'NDCG@10': '0.4539', 'MRR': '0.3804'} 36 | {'epoch': 17, 'rec_avg_loss': '0.4459', 'rec_cur_loss': '0.4563'} 37 | {'Epoch': 17, 'HIT@1': '0.2244', 'NDCG@1': '0.2244', 'HIT@5': '0.5603', 'NDCG@5': '0.3972', 'HIT@10': '0.7370', 'NDCG@10': '0.4545', 'MRR': '0.3820'} 38 | {'epoch': 18, 'rec_avg_loss': '0.4374', 'rec_cur_loss': '0.4404'} 39 | {'Epoch': 18, 'HIT@1': '0.2231', 'NDCG@1': '0.2231', 'HIT@5': '0.5621', 'NDCG@5': '0.3977', 'HIT@10': '0.7414', 'NDCG@10': '0.4559', 'MRR': '0.3821'} 40 | {'epoch': 19, 'rec_avg_loss': '0.4292', 'rec_cur_loss': '0.4502'} 41 | {'Epoch': 19, 'HIT@1': '0.2246', 'NDCG@1': '0.2246', 'HIT@5': '0.5647', 'NDCG@5': '0.3994', 'HIT@10': '0.7424', 'NDCG@10': '0.4569', 'MRR': '0.3830'} 42 | {'epoch': 20, 'rec_avg_loss': '0.4212', 'rec_cur_loss': '0.4176'} 43 | {'Epoch': 20, 'HIT@1': '0.2279', 'NDCG@1': '0.2279', 'HIT@5': '0.5652', 'NDCG@5': '0.4014', 'HIT@10': '0.7457', 'NDCG@10': '0.4598', 'MRR': '0.3857'} 44 | {'epoch': 21, 'rec_avg_loss': '0.4135', 'rec_cur_loss': '0.4374'} 45 | {'Epoch': 21, 'HIT@1': '0.2297', 'NDCG@1': '0.2297', 'HIT@5': '0.5653', 'NDCG@5': '0.4026', 'HIT@10': '0.7455', 'NDCG@10': '0.4610', 'MRR': '0.3873'} 46 | {'epoch': 22, 'rec_avg_loss': '0.4084', 'rec_cur_loss': '0.3904'} 47 | {'Epoch': 22, 'HIT@1': '0.2295', 'NDCG@1': '0.2295', 'HIT@5': '0.5683', 'NDCG@5': '0.4038', 'HIT@10': '0.7467', 'NDCG@10': '0.4617', 'MRR': '0.3877'} 48 | {'epoch': 23, 'rec_avg_loss': '0.4018', 'rec_cur_loss': '0.4333'} 49 | {'Epoch': 23, 'HIT@1': '0.2321', 'NDCG@1': '0.2321', 'HIT@5': '0.5696', 'NDCG@5': '0.4059', 'HIT@10': '0.7484', 'NDCG@10': '0.4638', 'MRR': '0.3898'} 50 | {'epoch': 24, 'rec_avg_loss': '0.3940', 'rec_cur_loss': '0.4121'} 51 | {'Epoch': 24, 'HIT@1': '0.2318', 'NDCG@1': '0.2318', 'HIT@5': '0.5708', 'NDCG@5': '0.4064', 'HIT@10': '0.7497', 'NDCG@10': '0.4644', 'MRR': '0.3900'} 52 | {'epoch': 25, 'rec_avg_loss': '0.3930', 'rec_cur_loss': '0.3842'} 53 | {'Epoch': 25, 'HIT@1': '0.2330', 'NDCG@1': '0.2330', 'HIT@5': '0.5750', 'NDCG@5': '0.4094', 'HIT@10': '0.7492', 'NDCG@10': '0.4657', 'MRR': '0.3918'} 54 | {'epoch': 26, 'rec_avg_loss': '0.3866', 'rec_cur_loss': '0.3869'} 55 | {'Epoch': 26, 'HIT@1': '0.2342', 'NDCG@1': '0.2342', 'HIT@5': '0.5737', 'NDCG@5': '0.4093', 'HIT@10': '0.7498', 'NDCG@10': '0.4664', 'MRR': '0.3926'} 56 | {'epoch': 27, 'rec_avg_loss': '0.3800', 'rec_cur_loss': '0.4247'} 57 | {'Epoch': 27, 'HIT@1': '0.2336', 'NDCG@1': '0.2336', 'HIT@5': '0.5740', 'NDCG@5': '0.4092', 'HIT@10': '0.7514', 'NDCG@10': '0.4668', 'MRR': '0.3924'} 58 | {'epoch': 28, 'rec_avg_loss': '0.3775', 'rec_cur_loss': '0.3702'} 59 | {'Epoch': 28, 'HIT@1': '0.2346', 'NDCG@1': '0.2346', 'HIT@5': '0.5772', 'NDCG@5': '0.4113', 'HIT@10': '0.7533', 'NDCG@10': '0.4684', 'MRR': '0.3937'} 60 | {'epoch': 29, 'rec_avg_loss': '0.3713', 'rec_cur_loss': '0.3818'} 61 | {'Epoch': 29, 'HIT@1': '0.2344', 'NDCG@1': '0.2344', 'HIT@5': '0.5768', 'NDCG@5': '0.4106', 'HIT@10': '0.7531', 'NDCG@10': '0.4677', 'MRR': '0.3929'} 62 | {'epoch': 30, 'rec_avg_loss': '0.3675', 'rec_cur_loss': '0.3316'} 63 | {'Epoch': 30, 'HIT@1': '0.2343', 'NDCG@1': '0.2343', 'HIT@5': '0.5761', 'NDCG@5': '0.4105', 'HIT@10': '0.7514', 'NDCG@10': '0.4674', 'MRR': '0.3931'} 64 | {'epoch': 31, 'rec_avg_loss': '0.3664', 'rec_cur_loss': '0.4063'} 65 | {'Epoch': 31, 'HIT@1': '0.2359', 'NDCG@1': '0.2359', 'HIT@5': '0.5741', 'NDCG@5': '0.4100', 'HIT@10': '0.7520', 'NDCG@10': '0.4677', 'MRR': '0.3934'} 66 | {'epoch': 32, 'rec_avg_loss': '0.3632', 'rec_cur_loss': '0.3881'} 67 | {'Epoch': 32, 'HIT@1': '0.2369', 'NDCG@1': '0.2369', 'HIT@5': '0.5758', 'NDCG@5': '0.4117', 'HIT@10': '0.7521', 'NDCG@10': '0.4688', 'MRR': '0.3947'} 68 | {'epoch': 33, 'rec_avg_loss': '0.3592', 'rec_cur_loss': '0.3677'} 69 | {'Epoch': 33, 'HIT@1': '0.2351', 'NDCG@1': '0.2351', 'HIT@5': '0.5763', 'NDCG@5': '0.4112', 'HIT@10': '0.7517', 'NDCG@10': '0.4681', 'MRR': '0.3939'} 70 | {'epoch': 34, 'rec_avg_loss': '0.3568', 'rec_cur_loss': '0.3516'} 71 | {'Epoch': 34, 'HIT@1': '0.2378', 'NDCG@1': '0.2378', 'HIT@5': '0.5813', 'NDCG@5': '0.4142', 'HIT@10': '0.7517', 'NDCG@10': '0.4694', 'MRR': '0.3955'} 72 | {'epoch': 35, 'rec_avg_loss': '0.3553', 'rec_cur_loss': '0.3385'} 73 | {'Epoch': 35, 'HIT@1': '0.2361', 'NDCG@1': '0.2361', 'HIT@5': '0.5786', 'NDCG@5': '0.4129', 'HIT@10': '0.7538', 'NDCG@10': '0.4696', 'MRR': '0.3950'} 74 | {'epoch': 36, 'rec_avg_loss': '0.3501', 'rec_cur_loss': '0.4031'} 75 | {'Epoch': 36, 'HIT@1': '0.2358', 'NDCG@1': '0.2358', 'HIT@5': '0.5801', 'NDCG@5': '0.4132', 'HIT@10': '0.7533', 'NDCG@10': '0.4692', 'MRR': '0.3947'} 76 | {'epoch': 37, 'rec_avg_loss': '0.3503', 'rec_cur_loss': '0.3667'} 77 | {'Epoch': 37, 'HIT@1': '0.2385', 'NDCG@1': '0.2385', 'HIT@5': '0.5811', 'NDCG@5': '0.4146', 'HIT@10': '0.7521', 'NDCG@10': '0.4700', 'MRR': '0.3962'} 78 | {'epoch': 38, 'rec_avg_loss': '0.3448', 'rec_cur_loss': '0.3451'} 79 | {'Epoch': 38, 'HIT@1': '0.2409', 'NDCG@1': '0.2409', 'HIT@5': '0.5830', 'NDCG@5': '0.4172', 'HIT@10': '0.7543', 'NDCG@10': '0.4728', 'MRR': '0.3990'} 80 | {'epoch': 39, 'rec_avg_loss': '0.3431', 'rec_cur_loss': '0.3734'} 81 | {'Epoch': 39, 'HIT@1': '0.2394', 'NDCG@1': '0.2394', 'HIT@5': '0.5817', 'NDCG@5': '0.4154', 'HIT@10': '0.7529', 'NDCG@10': '0.4711', 'MRR': '0.3971'} 82 | {'epoch': 40, 'rec_avg_loss': '0.3437', 'rec_cur_loss': '0.3754'} 83 | {'Epoch': 40, 'HIT@1': '0.2409', 'NDCG@1': '0.2409', 'HIT@5': '0.5837', 'NDCG@5': '0.4173', 'HIT@10': '0.7534', 'NDCG@10': '0.4724', 'MRR': '0.3988'} 84 | {'epoch': 41, 'rec_avg_loss': '0.3429', 'rec_cur_loss': '0.3430'} 85 | {'Epoch': 41, 'HIT@1': '0.2400', 'NDCG@1': '0.2400', 'HIT@5': '0.5828', 'NDCG@5': '0.4166', 'HIT@10': '0.7546', 'NDCG@10': '0.4724', 'MRR': '0.3982'} 86 | {'epoch': 42, 'rec_avg_loss': '0.3412', 'rec_cur_loss': '0.3762'} 87 | {'Epoch': 42, 'HIT@1': '0.2394', 'NDCG@1': '0.2394', 'HIT@5': '0.5828', 'NDCG@5': '0.4173', 'HIT@10': '0.7558', 'NDCG@10': '0.4734', 'MRR': '0.3991'} 88 | {'epoch': 43, 'rec_avg_loss': '0.3362', 'rec_cur_loss': '0.3177'} 89 | {'Epoch': 43, 'HIT@1': '0.2414', 'NDCG@1': '0.2414', 'HIT@5': '0.5833', 'NDCG@5': '0.4184', 'HIT@10': '0.7560', 'NDCG@10': '0.4744', 'MRR': '0.4004'} 90 | {'epoch': 44, 'rec_avg_loss': '0.3350', 'rec_cur_loss': '0.3428'} 91 | {'Epoch': 44, 'HIT@1': '0.2407', 'NDCG@1': '0.2407', 'HIT@5': '0.5803', 'NDCG@5': '0.4162', 'HIT@10': '0.7543', 'NDCG@10': '0.4727', 'MRR': '0.3988'} 92 | {'epoch': 45, 'rec_avg_loss': '0.3352', 'rec_cur_loss': '0.3427'} 93 | {'Epoch': 45, 'HIT@1': '0.2395', 'NDCG@1': '0.2395', 'HIT@5': '0.5833', 'NDCG@5': '0.4172', 'HIT@10': '0.7542', 'NDCG@10': '0.4727', 'MRR': '0.3987'} 94 | {'epoch': 46, 'rec_avg_loss': '0.3325', 'rec_cur_loss': '0.3265'} 95 | {'Epoch': 46, 'HIT@1': '0.2405', 'NDCG@1': '0.2405', 'HIT@5': '0.5852', 'NDCG@5': '0.4186', 'HIT@10': '0.7564', 'NDCG@10': '0.4741', 'MRR': '0.3997'} 96 | {'epoch': 47, 'rec_avg_loss': '0.3286', 'rec_cur_loss': '0.3821'} 97 | {'Epoch': 47, 'HIT@1': '0.2433', 'NDCG@1': '0.2433', 'HIT@5': '0.5890', 'NDCG@5': '0.4216', 'HIT@10': '0.7550', 'NDCG@10': '0.4753', 'MRR': '0.4017'} 98 | {'epoch': 48, 'rec_avg_loss': '0.3303', 'rec_cur_loss': '0.3215'} 99 | {'Epoch': 48, 'HIT@1': '0.2411', 'NDCG@1': '0.2411', 'HIT@5': '0.5854', 'NDCG@5': '0.4186', 'HIT@10': '0.7533', 'NDCG@10': '0.4731', 'MRR': '0.3995'} 100 | {'epoch': 49, 'rec_avg_loss': '0.3274', 'rec_cur_loss': '0.3567'} 101 | {'Epoch': 49, 'HIT@1': '0.2413', 'NDCG@1': '0.2413', 'HIT@5': '0.5860', 'NDCG@5': '0.4198', 'HIT@10': '0.7565', 'NDCG@10': '0.4752', 'MRR': '0.4009'} 102 | {'epoch': 50, 'rec_avg_loss': '0.3311', 'rec_cur_loss': '0.3244'} 103 | {'Epoch': 50, 'HIT@1': '0.2429', 'NDCG@1': '0.2429', 'HIT@5': '0.5847', 'NDCG@5': '0.4193', 'HIT@10': '0.7536', 'NDCG@10': '0.4741', 'MRR': '0.4008'} 104 | {'epoch': 51, 'rec_avg_loss': '0.3235', 'rec_cur_loss': '0.3252'} 105 | {'Epoch': 51, 'HIT@1': '0.2423', 'NDCG@1': '0.2423', 'HIT@5': '0.5849', 'NDCG@5': '0.4195', 'HIT@10': '0.7553', 'NDCG@10': '0.4747', 'MRR': '0.4009'} 106 | {'epoch': 52, 'rec_avg_loss': '0.3259', 'rec_cur_loss': '0.3491'} 107 | {'Epoch': 52, 'HIT@1': '0.2414', 'NDCG@1': '0.2414', 'HIT@5': '0.5852', 'NDCG@5': '0.4191', 'HIT@10': '0.7556', 'NDCG@10': '0.4743', 'MRR': '0.4003'} 108 | {'epoch': 53, 'rec_avg_loss': '0.3220', 'rec_cur_loss': '0.3141'} 109 | {'Epoch': 53, 'HIT@1': '0.2423', 'NDCG@1': '0.2423', 'HIT@5': '0.5852', 'NDCG@5': '0.4196', 'HIT@10': '0.7544', 'NDCG@10': '0.4745', 'MRR': '0.4009'} 110 | {'epoch': 54, 'rec_avg_loss': '0.3226', 'rec_cur_loss': '0.3077'} 111 | {'Epoch': 54, 'HIT@1': '0.2407', 'NDCG@1': '0.2407', 'HIT@5': '0.5870', 'NDCG@5': '0.4199', 'HIT@10': '0.7574', 'NDCG@10': '0.4753', 'MRR': '0.4007'} 112 | {'epoch': 55, 'rec_avg_loss': '0.3197', 'rec_cur_loss': '0.3393'} 113 | {'Epoch': 55, 'HIT@1': '0.2420', 'NDCG@1': '0.2420', 'HIT@5': '0.5851', 'NDCG@5': '0.4193', 'HIT@10': '0.7555', 'NDCG@10': '0.4747', 'MRR': '0.4006'} 114 | {'epoch': 56, 'rec_avg_loss': '0.3219', 'rec_cur_loss': '0.3296'} 115 | {'Epoch': 56, 'HIT@1': '0.2412', 'NDCG@1': '0.2412', 'HIT@5': '0.5859', 'NDCG@5': '0.4188', 'HIT@10': '0.7544', 'NDCG@10': '0.4735', 'MRR': '0.3995'} 116 | {'epoch': 57, 'rec_avg_loss': '0.3178', 'rec_cur_loss': '0.3402'} 117 | {'Epoch': 57, 'HIT@1': '0.2407', 'NDCG@1': '0.2407', 'HIT@5': '0.5856', 'NDCG@5': '0.4187', 'HIT@10': '0.7558', 'NDCG@10': '0.4741', 'MRR': '0.3997'} 118 | {'Epoch': 0, 'HIT@1': '0.2310', 'NDCG@1': '0.2310', 'HIT@5': '0.5638', 'NDCG@5': '0.4017', 'HIT@10': '0.7384', 'NDCG@10': '0.4582', 'MRR': '0.3856'} 119 | Finetune_sample-Yelp-0 120 | {'Epoch': 0, 'HIT@1': '0.2310', 'NDCG@1': '0.2310', 'HIT@5': '0.5638', 'NDCG@5': '0.4017', 'HIT@10': '0.7384', 'NDCG@10': '0.4582', 'MRR': '0.3856'} 121 | -------------------------------------------------------------------------------- /reproduce/LastFM-epochs-150.pt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RUCAIBox/CIKM2020-S3Rec/2a81540ae18615d88ef88227b0c066e5b74781e5/reproduce/LastFM-epochs-150.pt -------------------------------------------------------------------------------- /reproduce/README.md: -------------------------------------------------------------------------------- 1 | We release the pre-trained models for reproducibility. 2 | ``` 3 | {data-name}-epochs-{pretrain_epochs_num}.pt 4 | ``` 5 | The log files are also released and the '-0' means without pre-training. 6 | ``` 7 | Finetune_sample-{data-name}-epochs-0.pt 8 | Finetune_sample-{data-name}-epochs-{pretrain_epochs_num}.pt 9 | ``` 10 | ## Note 11 | 12 | There is a minor bug in the old version codes, which is that we did not set the random seed for all random methods. 13 | We are very sorry for this error. 14 | And we deleted pre-trained models considering the disk space. So we re-run the code and get new results, which could be 15 | considered as reproduced the results in the paper. 16 | 17 | When you fine-tune the model, please check the log information. If it is 18 | ``` 19 | ckp_file Not Found! The Model is the same as SASRec. 20 | ``` 21 | then you actually run the SASRec and the model's parameters are initialized randomly. Otherwise, you would see 22 | ``` 23 | Load Checkpoint From ckp_path! 24 | ``` 25 | which means you successfully initialize the model with pre-trained parameters. 26 | 27 | ### Meituan 28 | 29 | Considering the **data security** issues, this dataset will not release. 30 | 31 | ### Beauty 32 | 33 | | Model | HR@1 | HR@5 | NDCG@5 | HR@10 | NDCG@10 | MRR | 34 | |-----------------|------|------|--------|-------|---------|------| 35 | | SASRec in paper |0.1870|0.3741|0.2848 |0.4696 |0.3156 |0.2852| 36 | | SASRec in repo |0.1867|0.3721|0.2843 |0.4651 |0.3142 |0.2850| 37 | | S3-Rec in paper |0.2192|0.4502|0.3407 |0.5506 |0.3732 |0.3340| 38 | | S3-Rec in repo |0.2197|0.4626|0.3473 |0.5687 |0.3816 |0.3390| 39 | 40 | + pretrain (just use the default hyper-parameters) 41 | ```shell script 42 | python run_pretrain.py \ 43 | --data_name Beauty 44 | ``` 45 | 46 | + finetune (just use the default hyper-parameters) 47 | ```shell script 48 | python run_finetune_sample.py \ 49 | --data_name Beauty \ 50 | --ckp 150 51 | ``` 52 | 53 | ### Sports_and_Outdoors 54 | 55 | | Model | HR@1 | HR@5 | NDCG@5 | HR@10 | NDCG@10 | MRR | 56 | |-----------------|------|------|--------|-------|---------|------| 57 | | SASRec in paper |0.1455|0.3466|0.2497 |0.4622 |0.2869 |0.2520| 58 | | SASRec in repo |0.1472|0.3441|0.2487 |0.4645 |0.3875 |0.2524| 59 | | S3-Rec in paper |0.1841|0.4267|0.3104 |0.5614 |0.3538 |0.3071| 60 | | S3-Rec in repo |0.1840|0.4319|0.3125 |0.5664 |0.3559 |0.3084| 61 | 62 | + pretrain (just use the default hyper-parameters) 63 | ```shell script 64 | python run_pretrain.py \ 65 | --data_name Sports_and_Outdoors 66 | ``` 67 | 68 | + finetune (just use the default hyper-parameters) 69 | ```shell script 70 | python run_finetune_sample.py \ 71 | --data_name Sports_and_Outdoors \ 72 | --ckp 100 73 | ``` 74 | 75 | ### Toys_and_Games 76 | 77 | | Model | HR@1 | HR@5 | NDCG@5 | HR@10 | NDCG@10 | MRR | 78 | |-----------------|------|------|--------|-------|---------|------| 79 | | SASRec in paper |0.1878|0.3682|0.2820 |0.4663 |0.3136 |0.2842| 80 | | SASRec in repo |0.1775|0.3683|0.2766 |0.4659 |0.3081 |0.2770| 81 | | S3-Rec in paper |0.2003|0.4420|0.3270 |0.5530 |0.3629 |0.3202| 82 | | S3-Rec in repo |0.2070|0.4481|0.3335 |0.5593 |0.3695 |0.3268| 83 | 84 | + pretrain (just use the default hyper-parameters) 85 | ```shell script 86 | python run_pretrain.py \ 87 | --data_name Toys_and_Games 88 | ``` 89 | 90 | + finetune (just use the default hyper-parameters) 91 | ```shell script 92 | python run_finetune_sample.py \ 93 | --data_name Toys_and_Games \ 94 | --ckp 150 95 | ``` 96 | 97 | ### Yelp 98 | 99 | | Model | HR@1 | HR@5 | NDCG@5 | HR@10 | NDCG@10 | MRR | 100 | |-----------------|------|------|--------|-------|---------|------| 101 | | SASRec in paper |0.2375|0.5745|0.4113 |0.7373 |0.4642 |0.3927| 102 | | SASRec in repo |0.2310|0.5638|0.4017 |0.7384 |0.4582 |0.3856| 103 | | S3-Rec in paper |0.2591|0.6085|0.4401 |0.7725 |0.4934 |0.4190| 104 | | S3-Rec in repo |0.2665|0.6195|0.4492 |0.7818 |0.5019 |0.4270| 105 | 106 | + pretrain (just use the default hyper-parameters) 107 | ```shell script 108 | python run_pretrain.py \ 109 | --data_name Yelp 110 | ``` 111 | 112 | + finetune (just use the default hyper-parameters) 113 | ```shell script 114 | python run_finetune_sample.py \ 115 | --data_name Yelp \ 116 | --ckp 100 117 | ``` 118 | 119 | ### LastFM 120 | 121 | | Model | HR@1 | HR@5 | NDCG@5 | HR@10 | NDCG@10 | MRR | 122 | |-----------------|------|------|--------|-------|---------|------| 123 | | SASRec in paper |0.1211|0.3385|0.2330 |0.4706 |0.2755 |0.2364| 124 | | SASRec in repo |0.1156|0.3092|0.2126 |0.4587 |0.2605 |0.2209| 125 | | S3-Rec in paper |0.1743|0.4523|0.3156 |0.5835 |0.3583 |0.3072| 126 | | S3-Rec in repo |0.1569|0.4477|0.3056 |0.6083 |0.3577 |0.2981| 127 | 128 | + pretrain (just use the default hyper-parameters) 129 | ```shell script 130 | python run_pretrain.py \ 131 | --data_name LastFM 132 | ``` 133 | 134 | + finetune (just use the default hyper-parameters) 135 | ```shell script 136 | python run_finetune_sample.py \ 137 | --data_name LastFM \ 138 | --ckp 150 139 | ``` 140 | 141 | -------------------------------------------------------------------------------- /reproduce/Sports_and_Outdoors-epochs-100.pt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RUCAIBox/CIKM2020-S3Rec/2a81540ae18615d88ef88227b0c066e5b74781e5/reproduce/Sports_and_Outdoors-epochs-100.pt -------------------------------------------------------------------------------- /reproduce/Toys_and_Games-epochs-150.pt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RUCAIBox/CIKM2020-S3Rec/2a81540ae18615d88ef88227b0c066e5b74781e5/reproduce/Toys_and_Games-epochs-150.pt -------------------------------------------------------------------------------- /reproduce/Yelp-epochs-100.pt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RUCAIBox/CIKM2020-S3Rec/2a81540ae18615d88ef88227b0c066e5b74781e5/reproduce/Yelp-epochs-100.pt -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | torch==1.1.0 2 | numpy==1.19.1 3 | scipy==1.5.2 4 | tqdm==4.48.2 -------------------------------------------------------------------------------- /run_finetune_full.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @Time : 2020/4/25 22:59 3 | # @Author : Hui Wang 4 | 5 | import os 6 | import numpy as np 7 | import random 8 | import torch 9 | import argparse 10 | 11 | from torch.utils.data import DataLoader, RandomSampler, SequentialSampler 12 | 13 | from datasets import SASRecDataset 14 | from trainers import FinetuneTrainer 15 | from models import S3RecModel 16 | from utils import EarlyStopping, get_user_seqs, get_item2attribute_json, check_path, set_seed 17 | 18 | def main(): 19 | parser = argparse.ArgumentParser() 20 | 21 | parser.add_argument('--data_dir', default='./data/', type=str) 22 | parser.add_argument('--output_dir', default='output/', type=str) 23 | parser.add_argument('--data_name', default='Beauty', type=str) 24 | parser.add_argument('--do_eval', action='store_true') 25 | parser.add_argument('--ckp', default=10, type=int, help="pretrain epochs 10, 20, 30...") 26 | 27 | # model args 28 | parser.add_argument("--model_name", default='Finetune_full', type=str) 29 | parser.add_argument("--hidden_size", type=int, default=64, help="hidden size of transformer model") 30 | parser.add_argument("--num_hidden_layers", type=int, default=2, help="number of layers") 31 | parser.add_argument('--num_attention_heads', default=2, type=int) 32 | parser.add_argument('--hidden_act', default="gelu", type=str) # gelu relu 33 | parser.add_argument("--attention_probs_dropout_prob", type=float, default=0.5, help="attention dropout p") 34 | parser.add_argument("--hidden_dropout_prob", type=float, default=0.5, help="hidden dropout p") 35 | parser.add_argument("--initializer_range", type=float, default=0.02) 36 | parser.add_argument('--max_seq_length', default=50, type=int) 37 | 38 | # train args 39 | parser.add_argument("--lr", type=float, default=0.001, help="learning rate of adam") 40 | parser.add_argument("--batch_size", type=int, default=256, help="number of batch_size") 41 | parser.add_argument("--epochs", type=int, default=200, help="number of epochs") 42 | parser.add_argument("--no_cuda", action="store_true") 43 | parser.add_argument("--log_freq", type=int, default=1, help="per epoch print res") 44 | parser.add_argument("--seed", default=42, type=int) 45 | 46 | parser.add_argument("--weight_decay", type=float, default=0.0, help="weight_decay of adam") 47 | parser.add_argument("--adam_beta1", type=float, default=0.9, help="adam first beta value") 48 | parser.add_argument("--adam_beta2", type=float, default=0.999, help="adam second beta value") 49 | parser.add_argument("--gpu_id", type=str, default="0", help="gpu_id") 50 | 51 | args = parser.parse_args() 52 | 53 | set_seed(args.seed) 54 | check_path(args.output_dir) 55 | 56 | 57 | os.environ["CUDA_VISIBLE_DEVICES"] = args.gpu_id 58 | args.cuda_condition = torch.cuda.is_available() and not args.no_cuda 59 | 60 | args.data_file = args.data_dir + args.data_name + '.txt' 61 | item2attribute_file = args.data_dir + args.data_name + '_item2attributes.json' 62 | 63 | user_seq, max_item, valid_rating_matrix, test_rating_matrix = \ 64 | get_user_seqs(args.data_file) 65 | 66 | item2attribute, attribute_size = get_item2attribute_json(item2attribute_file) 67 | 68 | args.item_size = max_item + 2 69 | args.mask_id = max_item + 1 70 | args.attribute_size = attribute_size + 1 71 | 72 | # save model args 73 | args_str = f'{args.model_name}-{args.data_name}-{args.ckp}' 74 | args.log_file = os.path.join(args.output_dir, args_str + '.txt') 75 | print(str(args)) 76 | with open(args.log_file, 'a') as f: 77 | f.write(str(args) + '\n') 78 | 79 | args.item2attribute = item2attribute 80 | # set item score in train set to `0` in validation 81 | args.train_matrix = valid_rating_matrix 82 | 83 | # save model 84 | checkpoint = args_str + '.pt' 85 | args.checkpoint_path = os.path.join(args.output_dir, checkpoint) 86 | 87 | train_dataset = SASRecDataset(args, user_seq, data_type='train') 88 | train_sampler = RandomSampler(train_dataset) 89 | train_dataloader = DataLoader(train_dataset, sampler=train_sampler, batch_size=args.batch_size) 90 | 91 | eval_dataset = SASRecDataset(args, user_seq, data_type='valid') 92 | eval_sampler = SequentialSampler(eval_dataset) 93 | eval_dataloader = DataLoader(eval_dataset, sampler=eval_sampler, batch_size=args.batch_size) 94 | 95 | test_dataset = SASRecDataset(args, user_seq, data_type='test') 96 | test_sampler = SequentialSampler(test_dataset) 97 | test_dataloader = DataLoader(test_dataset, sampler=test_sampler, batch_size=args.batch_size) 98 | 99 | 100 | model = S3RecModel(args=args) 101 | 102 | trainer = FinetuneTrainer(model, train_dataloader, eval_dataloader, 103 | test_dataloader, args) 104 | 105 | 106 | if args.do_eval: 107 | trainer.load(args.checkpoint_path) 108 | print(f'Load model from {args.checkpoint_path} for test!') 109 | scores, result_info = trainer.test(0, full_sort=True) 110 | 111 | else: 112 | pretrained_path = os.path.join(args.output_dir, f'{args.data_name}-epochs-{args.ckp}.pt') 113 | try: 114 | trainer.load(pretrained_path) 115 | print(f'Load Checkpoint From {pretrained_path}!') 116 | 117 | except FileNotFoundError: 118 | print(f'{pretrained_path} Not Found! The Model is same as SASRec') 119 | 120 | early_stopping = EarlyStopping(args.checkpoint_path, patience=10, verbose=True) 121 | for epoch in range(args.epochs): 122 | trainer.train(epoch) 123 | # evaluate on NDCG@20 124 | scores, _ = trainer.valid(epoch, full_sort=True) 125 | early_stopping(np.array(scores[-1:]), trainer.model) 126 | if early_stopping.early_stop: 127 | print("Early stopping") 128 | break 129 | 130 | trainer.args.train_matrix = test_rating_matrix 131 | print('---------------Change to test_rating_matrix!-------------------') 132 | # load the best model 133 | trainer.model.load_state_dict(torch.load(args.checkpoint_path)) 134 | scores, result_info = trainer.test(0, full_sort=True) 135 | 136 | print(args_str) 137 | print(result_info) 138 | with open(args.log_file, 'a') as f: 139 | f.write(args_str + '\n') 140 | f.write(result_info + '\n') 141 | main() -------------------------------------------------------------------------------- /run_finetune_sample.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @Time : 2020/11/5 21:11 3 | # @Author : Hui Wang 4 | 5 | import os 6 | import numpy as np 7 | import random 8 | import torch 9 | import argparse 10 | 11 | from torch.utils.data import DataLoader, RandomSampler, SequentialSampler 12 | 13 | from datasets import SASRecDataset 14 | from trainers import FinetuneTrainer 15 | from models import S3RecModel 16 | from utils import EarlyStopping, get_user_seqs_and_sample, get_item2attribute_json, check_path, set_seed 17 | 18 | def main(): 19 | parser = argparse.ArgumentParser() 20 | 21 | parser.add_argument('--data_dir', default='./data/', type=str) 22 | parser.add_argument('--output_dir', default='output/', type=str) 23 | parser.add_argument('--data_name', default='Beauty', type=str) 24 | parser.add_argument('--do_eval', action='store_true') 25 | parser.add_argument('--ckp', default=10, type=int, help="pretrain epochs 10, 20, 30...") 26 | 27 | # model args 28 | parser.add_argument("--model_name", default='Finetune_sample', type=str) 29 | parser.add_argument("--hidden_size", type=int, default=64, help="hidden size of transformer model") 30 | parser.add_argument("--num_hidden_layers", type=int, default=2, help="number of layers") 31 | parser.add_argument('--num_attention_heads', default=2, type=int) 32 | parser.add_argument('--hidden_act', default="gelu", type=str) # gelu relu 33 | parser.add_argument("--attention_probs_dropout_prob", type=float, default=0.5, help="attention dropout p") 34 | parser.add_argument("--hidden_dropout_prob", type=float, default=0.5, help="hidden dropout p") 35 | parser.add_argument("--initializer_range", type=float, default=0.02) 36 | parser.add_argument('--max_seq_length', default=50, type=int) 37 | 38 | # train args 39 | parser.add_argument("--lr", type=float, default=0.001, help="learning rate of adam") 40 | parser.add_argument("--batch_size", type=int, default=256, help="number of batch_size") 41 | parser.add_argument("--epochs", type=int, default=200, help="number of epochs") 42 | parser.add_argument("--no_cuda", action="store_true") 43 | parser.add_argument("--log_freq", type=int, default=1, help="per epoch print res") 44 | parser.add_argument("--seed", default=42, type=int) 45 | 46 | parser.add_argument("--weight_decay", type=float, default=0.0, help="weight_decay of adam") 47 | parser.add_argument("--adam_beta1", type=float, default=0.9, help="adam first beta value") 48 | parser.add_argument("--adam_beta2", type=float, default=0.999, help="adam second beta value") 49 | parser.add_argument("--gpu_id", type=str, default="0", help="gpu_id") 50 | 51 | args = parser.parse_args() 52 | 53 | set_seed(args.seed) 54 | check_path(args.output_dir) 55 | 56 | 57 | os.environ["CUDA_VISIBLE_DEVICES"] = args.gpu_id 58 | args.cuda_condition = torch.cuda.is_available() and not args.no_cuda 59 | 60 | args.data_file = args.data_dir + args.data_name + '.txt' 61 | args.sample_file = args.data_dir + args.data_name + '_sample.txt' 62 | item2attribute_file = args.data_dir + args.data_name + '_item2attributes.json' 63 | 64 | user_seq, max_item, sample_seq = \ 65 | get_user_seqs_and_sample(args.data_file, args.sample_file) 66 | 67 | item2attribute, attribute_size = get_item2attribute_json(item2attribute_file) 68 | 69 | args.item_size = max_item + 2 70 | args.mask_id = max_item + 1 71 | args.attribute_size = attribute_size + 1 72 | 73 | # save model args 74 | args_str = f'{args.model_name}-{args.data_name}-{args.ckp}' 75 | args.log_file = os.path.join(args.output_dir, args_str + '.txt') 76 | print(str(args)) 77 | with open(args.log_file, 'a') as f: 78 | f.write(str(args) + '\n') 79 | 80 | args.item2attribute = item2attribute 81 | 82 | # save model 83 | checkpoint = args_str + '.pt' 84 | args.checkpoint_path = os.path.join(args.output_dir, checkpoint) 85 | 86 | train_dataset = SASRecDataset(args, user_seq, data_type='train') 87 | train_sampler = RandomSampler(train_dataset) 88 | train_dataloader = DataLoader(train_dataset, sampler=train_sampler, batch_size=args.batch_size) 89 | 90 | eval_dataset = SASRecDataset(args, user_seq, test_neg_items=sample_seq, data_type='valid') 91 | eval_sampler = SequentialSampler(eval_dataset) 92 | eval_dataloader = DataLoader(eval_dataset, sampler=eval_sampler, batch_size=args.batch_size) 93 | 94 | test_dataset = SASRecDataset(args, user_seq, test_neg_items=sample_seq, data_type='test') 95 | test_sampler = SequentialSampler(test_dataset) 96 | test_dataloader = DataLoader(test_dataset, sampler=test_sampler, batch_size=args.batch_size) 97 | 98 | 99 | model = S3RecModel(args=args) 100 | 101 | trainer = FinetuneTrainer(model, train_dataloader, eval_dataloader, 102 | test_dataloader, args) 103 | 104 | 105 | if args.do_eval: 106 | trainer.load(args.checkpoint_path) 107 | print(f'Load model from {args.checkpoint_path} for test!') 108 | scores, result_info = trainer.test(0, full_sort=False) 109 | 110 | else: 111 | pretrained_path = os.path.join(args.output_dir, f'{args.data_name}-epochs-{args.ckp}.pt') 112 | try: 113 | trainer.load(pretrained_path) 114 | print(f'Load Checkpoint From {pretrained_path}!') 115 | 116 | except FileNotFoundError: 117 | print(f'{pretrained_path} Not Found! The Model is same as SASRec') 118 | 119 | early_stopping = EarlyStopping(args.checkpoint_path, patience=10, verbose=True) 120 | for epoch in range(args.epochs): 121 | trainer.train(epoch) 122 | scores, _ = trainer.valid(epoch, full_sort=False) 123 | # evaluate on MRR 124 | early_stopping(np.array(scores[-1:]), trainer.model) 125 | if early_stopping.early_stop: 126 | print("Early stopping") 127 | break 128 | 129 | print('---------------Sample 99 results-------------------') 130 | # load the best model 131 | trainer.model.load_state_dict(torch.load(args.checkpoint_path)) 132 | scores, result_info = trainer.test(0, full_sort=False) 133 | 134 | print(args_str) 135 | print(result_info) 136 | with open(args.log_file, 'a') as f: 137 | f.write(args_str + '\n') 138 | f.write(result_info + '\n') 139 | main() -------------------------------------------------------------------------------- /run_pretrain.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @Time : 2020/4/25 16:01 3 | # @Author : Hui Wang 4 | 5 | import numpy as np 6 | import random 7 | import torch 8 | from torch.utils.data import DataLoader, RandomSampler 9 | 10 | import os 11 | import argparse 12 | 13 | from datasets import PretrainDataset 14 | from trainers import PretrainTrainer 15 | from models import S3RecModel 16 | 17 | 18 | from utils import get_user_seqs_long, get_item2attribute_json, check_path, set_seed 19 | 20 | def main(): 21 | parser = argparse.ArgumentParser() 22 | 23 | parser.add_argument('--data_dir', default='./data/', type=str) 24 | parser.add_argument('--output_dir', default='output/', type=str) 25 | parser.add_argument('--data_name', default='Beauty', type=str) 26 | 27 | # model args 28 | parser.add_argument("--model_name", default='Pretrain', type=str) 29 | 30 | parser.add_argument("--hidden_size", type=int, default=64, help="hidden size of transformer model") 31 | parser.add_argument("--num_hidden_layers", type=int, default=2, help="number of layers") 32 | parser.add_argument('--num_attention_heads', default=2, type=int) 33 | parser.add_argument('--hidden_act', default="gelu", type=str) # gelu relu 34 | parser.add_argument("--attention_probs_dropout_prob", type=float, default=0.5, help="attention dropout p") 35 | parser.add_argument("--hidden_dropout_prob", type=float, default=0.5, help="hidden dropout p") 36 | parser.add_argument("--initializer_range", type=float, default=0.02) 37 | parser.add_argument('--max_seq_length', default=50, type=int) 38 | 39 | # train args 40 | parser.add_argument("--lr", type=float, default=0.001, help="learning rate of adam") 41 | parser.add_argument("--batch_size", type=int, default=256, help="number of batch_size") 42 | parser.add_argument("--epochs", type=int, default=200, help="number of epochs") 43 | parser.add_argument("--no_cuda", action="store_true") 44 | parser.add_argument("--log_freq", type=int, default=1, help="per epoch print res") 45 | parser.add_argument("--seed", default=42, type=int) 46 | 47 | # pre train args 48 | parser.add_argument("--pre_epochs", type=int, default=300, help="number of pre_train epochs") 49 | parser.add_argument("--pre_batch_size", type=int, default=100) 50 | 51 | parser.add_argument("--mask_p", type=float, default=0.2, help="mask probability") 52 | parser.add_argument("--aap_weight", type=float, default=0.2, help="aap loss weight") 53 | parser.add_argument("--mip_weight", type=float, default=1.0, help="mip loss weight") 54 | parser.add_argument("--map_weight", type=float, default=1.0, help="map loss weight") 55 | parser.add_argument("--sp_weight", type=float, default=0.5, help="sp loss weight") 56 | 57 | parser.add_argument("--weight_decay", type=float, default=0.0, help="weight_decay of adam") 58 | parser.add_argument("--adam_beta1", type=float, default=0.9, help="adam first beta value") 59 | parser.add_argument("--adam_beta2", type=float, default=0.999, help="adam second beta value") 60 | parser.add_argument("--gpu_id", type=str, default="0", help="gpu_id") 61 | 62 | 63 | args = parser.parse_args() 64 | 65 | set_seed(args.seed) 66 | check_path(args.output_dir) 67 | 68 | os.environ["CUDA_VISIBLE_DEVICES"] = args.gpu_id 69 | args.cuda_condition = torch.cuda.is_available() and not args.no_cuda 70 | 71 | args.data_file = args.data_dir + args.data_name + '.txt' 72 | item2attribute_file = args.data_dir + args.data_name + '_item2attributes.json' 73 | # concat all user_seq get a long sequence, from which sample neg segment for SP 74 | user_seq, max_item, long_sequence = get_user_seqs_long(args.data_file) 75 | item2attribute, attribute_size = get_item2attribute_json(item2attribute_file) 76 | 77 | args.item_size = max_item + 2 78 | args.mask_id = max_item + 1 79 | args.attribute_size = attribute_size + 1 80 | # save model args 81 | args_str = f'{args.model_name}-{args.data_name}' 82 | args.log_file = os.path.join(args.output_dir, args_str + '.txt') 83 | print(args) 84 | with open(args.log_file, 'a') as f: 85 | f.write(str(args) + '\n') 86 | 87 | args.item2attribute = item2attribute 88 | 89 | model = S3RecModel(args=args) 90 | trainer = PretrainTrainer(model, None, None, None, args) 91 | 92 | for epoch in range(args.pre_epochs): 93 | 94 | pretrain_dataset = PretrainDataset(args, user_seq, long_sequence) 95 | pretrain_sampler = RandomSampler(pretrain_dataset) 96 | pretrain_dataloader = DataLoader(pretrain_dataset, sampler=pretrain_sampler, batch_size=args.pre_batch_size) 97 | 98 | trainer.pretrain(epoch, pretrain_dataloader) 99 | 100 | if (epoch+1) % 10 == 0: 101 | ckp = f'{args.data_name}-epochs-{epoch+1}.pt' 102 | checkpoint_path = os.path.join(args.output_dir, ckp) 103 | trainer.save(checkpoint_path) 104 | 105 | 106 | main() -------------------------------------------------------------------------------- /sample_99.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RUCAIBox/CIKM2020-S3Rec/2a81540ae18615d88ef88227b0c066e5b74781e5/sample_99.PNG -------------------------------------------------------------------------------- /trainers.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @Time : 2020/3/30 11:06 3 | # @Author : Hui Wang 4 | 5 | import numpy as np 6 | import tqdm 7 | import random 8 | 9 | import torch 10 | import torch.nn as nn 11 | from torch.optim import Adam 12 | 13 | from utils import recall_at_k, ndcg_k, get_metric 14 | 15 | 16 | class Trainer: 17 | def __init__(self, model, train_dataloader, 18 | eval_dataloader, 19 | test_dataloader, args): 20 | 21 | self.args = args 22 | self.cuda_condition = torch.cuda.is_available() and not self.args.no_cuda 23 | self.device = torch.device("cuda" if self.cuda_condition else "cpu") 24 | 25 | self.model = model 26 | if self.cuda_condition: 27 | self.model.cuda() 28 | 29 | # Setting the train and test data loader 30 | self.train_dataloader = train_dataloader 31 | self.eval_dataloader = eval_dataloader 32 | self.test_dataloader = test_dataloader 33 | 34 | # self.data_name = self.args.data_name 35 | betas = (self.args.adam_beta1, self.args.adam_beta2) 36 | self.optim = Adam(self.model.parameters(), lr=self.args.lr, betas=betas, weight_decay=self.args.weight_decay) 37 | 38 | print("Total Parameters:", sum([p.nelement() for p in self.model.parameters()])) 39 | self.criterion = nn.BCELoss() 40 | def train(self, epoch): 41 | self.iteration(epoch, self.train_dataloader) 42 | 43 | def valid(self, epoch, full_sort=False): 44 | return self.iteration(epoch, self.eval_dataloader, full_sort, train=False) 45 | 46 | def test(self, epoch, full_sort=False): 47 | return self.iteration(epoch, self.test_dataloader, full_sort, train=False) 48 | 49 | def iteration(self, epoch, dataloader, full_sort=False, train=True): 50 | raise NotImplementedError 51 | 52 | def get_sample_scores(self, epoch, pred_list): 53 | pred_list = (-pred_list).argsort().argsort()[:, 0] 54 | HIT_1, NDCG_1, MRR = get_metric(pred_list, 1) 55 | HIT_5, NDCG_5, MRR = get_metric(pred_list, 5) 56 | HIT_10, NDCG_10, MRR = get_metric(pred_list, 10) 57 | post_fix = { 58 | "Epoch": epoch, 59 | "HIT@1": '{:.4f}'.format(HIT_1), "NDCG@1": '{:.4f}'.format(NDCG_1), 60 | "HIT@5": '{:.4f}'.format(HIT_5), "NDCG@5": '{:.4f}'.format(NDCG_5), 61 | "HIT@10": '{:.4f}'.format(HIT_10), "NDCG@10": '{:.4f}'.format(NDCG_10), 62 | "MRR": '{:.4f}'.format(MRR), 63 | } 64 | print(post_fix) 65 | with open(self.args.log_file, 'a') as f: 66 | f.write(str(post_fix) + '\n') 67 | return [HIT_1, NDCG_1, HIT_5, NDCG_5, HIT_10, NDCG_10, MRR], str(post_fix) 68 | 69 | def get_full_sort_score(self, epoch, answers, pred_list): 70 | recall, ndcg = [], [] 71 | for k in [5, 10, 15, 20]: 72 | recall.append(recall_at_k(answers, pred_list, k)) 73 | ndcg.append(ndcg_k(answers, pred_list, k)) 74 | post_fix = { 75 | "Epoch": epoch, 76 | "HIT@5": '{:.4f}'.format(recall[0]), "NDCG@5": '{:.4f}'.format(ndcg[0]), 77 | "HIT@10": '{:.4f}'.format(recall[1]), "NDCG@10": '{:.4f}'.format(ndcg[1]), 78 | "HIT@20": '{:.4f}'.format(recall[3]), "NDCG@20": '{:.4f}'.format(ndcg[3]) 79 | } 80 | print(post_fix) 81 | with open(self.args.log_file, 'a') as f: 82 | f.write(str(post_fix) + '\n') 83 | return [recall[0], ndcg[0], recall[1], ndcg[1], recall[3], ndcg[3]], str(post_fix) 84 | 85 | def save(self, file_name): 86 | torch.save(self.model.cpu().state_dict(), file_name) 87 | self.model.to(self.device) 88 | 89 | def load(self, file_name): 90 | self.model.load_state_dict(torch.load(file_name)) 91 | 92 | def cross_entropy(self, seq_out, pos_ids, neg_ids): 93 | # [batch seq_len hidden_size] 94 | pos_emb = self.model.item_embeddings(pos_ids) 95 | neg_emb = self.model.item_embeddings(neg_ids) 96 | # [batch*seq_len hidden_size] 97 | pos = pos_emb.view(-1, pos_emb.size(2)) 98 | neg = neg_emb.view(-1, neg_emb.size(2)) 99 | seq_emb = seq_out.view(-1, self.args.hidden_size) # [batch*seq_len hidden_size] 100 | pos_logits = torch.sum(pos * seq_emb, -1) # [batch*seq_len] 101 | neg_logits = torch.sum(neg * seq_emb, -1) 102 | istarget = (pos_ids > 0).view(pos_ids.size(0) * self.model.args.max_seq_length).float() # [batch*seq_len] 103 | loss = torch.sum( 104 | - torch.log(torch.sigmoid(pos_logits) + 1e-24) * istarget - 105 | torch.log(1 - torch.sigmoid(neg_logits) + 1e-24) * istarget 106 | ) / torch.sum(istarget) 107 | 108 | return loss 109 | 110 | def predict_sample(self, seq_out, test_neg_sample): 111 | # [batch 100 hidden_size] 112 | test_item_emb = self.model.item_embeddings(test_neg_sample) 113 | # [batch hidden_size] 114 | test_logits = torch.bmm(test_item_emb, seq_out.unsqueeze(-1)).squeeze(-1) # [B 100] 115 | return test_logits 116 | 117 | def predict_full(self, seq_out): 118 | # [item_num hidden_size] 119 | test_item_emb = self.model.item_embeddings.weight 120 | # [batch hidden_size ] 121 | rating_pred = torch.matmul(seq_out, test_item_emb.transpose(0, 1)) 122 | return rating_pred 123 | 124 | class PretrainTrainer(Trainer): 125 | 126 | def __init__(self, model, 127 | train_dataloader, 128 | eval_dataloader, 129 | test_dataloader, args): 130 | super(PretrainTrainer, self).__init__( 131 | model, 132 | train_dataloader, 133 | eval_dataloader, 134 | test_dataloader, args 135 | ) 136 | 137 | def pretrain(self, epoch, pretrain_dataloader): 138 | 139 | desc = f'AAP-{self.args.aap_weight}-' \ 140 | f'MIP-{self.args.mip_weight}-' \ 141 | f'MAP-{self.args.map_weight}-' \ 142 | f'SP-{self.args.sp_weight}' 143 | 144 | pretrain_data_iter = tqdm.tqdm(enumerate(pretrain_dataloader), 145 | desc=f"{self.args.model_name}-{self.args.data_name} Epoch:{epoch}", 146 | total=len(pretrain_dataloader), 147 | bar_format="{l_bar}{r_bar}") 148 | 149 | self.model.train() 150 | aap_loss_avg = 0.0 151 | mip_loss_avg = 0.0 152 | map_loss_avg = 0.0 153 | sp_loss_avg = 0.0 154 | 155 | for i, batch in pretrain_data_iter: 156 | # 0. batch_data will be sent into the device(GPU or CPU) 157 | batch = tuple(t.to(self.device) for t in batch) 158 | attributes, masked_item_sequence, pos_items, neg_items, \ 159 | masked_segment_sequence, pos_segment, neg_segment = batch 160 | 161 | aap_loss, mip_loss, map_loss, sp_loss = self.model.pretrain(attributes, 162 | masked_item_sequence, pos_items, neg_items, 163 | masked_segment_sequence, pos_segment, neg_segment) 164 | 165 | joint_loss = self.args.aap_weight * aap_loss + \ 166 | self.args.mip_weight * mip_loss + \ 167 | self.args.map_weight * map_loss + \ 168 | self.args.sp_weight * sp_loss 169 | 170 | self.optim.zero_grad() 171 | joint_loss.backward() 172 | self.optim.step() 173 | 174 | aap_loss_avg += aap_loss.item() 175 | mip_loss_avg += mip_loss.item() 176 | map_loss_avg += map_loss.item() 177 | sp_loss_avg += sp_loss.item() 178 | 179 | num = len(pretrain_data_iter) * self.args.pre_batch_size 180 | post_fix = { 181 | "epoch": epoch, 182 | "aap_loss_avg": '{:.4f}'.format(aap_loss_avg /num), 183 | "mip_loss_avg": '{:.4f}'.format(mip_loss_avg /num), 184 | "map_loss_avg": '{:.4f}'.format(map_loss_avg / num), 185 | "sp_loss_avg": '{:.4f}'.format(sp_loss_avg / num), 186 | } 187 | print(desc) 188 | print(str(post_fix)) 189 | with open(self.args.log_file, 'a') as f: 190 | f.write(str(desc) + '\n') 191 | f.write(str(post_fix) + '\n') 192 | 193 | class FinetuneTrainer(Trainer): 194 | 195 | def __init__(self, model, 196 | train_dataloader, 197 | eval_dataloader, 198 | test_dataloader, args): 199 | super(FinetuneTrainer, self).__init__( 200 | model, 201 | train_dataloader, 202 | eval_dataloader, 203 | test_dataloader, args 204 | ) 205 | 206 | def iteration(self, epoch, dataloader, full_sort=False, train=True): 207 | 208 | str_code = "train" if train else "test" 209 | 210 | # Setting the tqdm progress bar 211 | 212 | rec_data_iter = tqdm.tqdm(enumerate(dataloader), 213 | desc="Recommendation EP_%s:%d" % (str_code, epoch), 214 | total=len(dataloader), 215 | bar_format="{l_bar}{r_bar}") 216 | if train: 217 | self.model.train() 218 | rec_avg_loss = 0.0 219 | rec_cur_loss = 0.0 220 | 221 | for i, batch in rec_data_iter: 222 | # 0. batch_data will be sent into the device(GPU or CPU) 223 | batch = tuple(t.to(self.device) for t in batch) 224 | _, input_ids, target_pos, target_neg, _ = batch 225 | # Binary cross_entropy 226 | sequence_output = self.model.finetune(input_ids) 227 | loss = self.cross_entropy(sequence_output, target_pos, target_neg) 228 | self.optim.zero_grad() 229 | loss.backward() 230 | self.optim.step() 231 | 232 | rec_avg_loss += loss.item() 233 | rec_cur_loss = loss.item() 234 | 235 | post_fix = { 236 | "epoch": epoch, 237 | "rec_avg_loss": '{:.4f}'.format(rec_avg_loss / len(rec_data_iter)), 238 | "rec_cur_loss": '{:.4f}'.format(rec_cur_loss), 239 | } 240 | 241 | if (epoch + 1) % self.args.log_freq == 0: 242 | print(str(post_fix)) 243 | 244 | with open(self.args.log_file, 'a') as f: 245 | f.write(str(post_fix) + '\n') 246 | 247 | else: 248 | self.model.eval() 249 | 250 | pred_list = None 251 | 252 | if full_sort: 253 | answer_list = None 254 | for i, batch in rec_data_iter: 255 | # 0. batch_data will be sent into the device(GPU or cpu) 256 | batch = tuple(t.to(self.device) for t in batch) 257 | user_ids, input_ids, target_pos, target_neg, answers = batch 258 | recommend_output = self.model.finetune(input_ids) 259 | 260 | recommend_output = recommend_output[:, -1, :] 261 | # 推荐的结果 262 | 263 | rating_pred = self.predict_full(recommend_output) 264 | 265 | rating_pred = rating_pred.cpu().data.numpy().copy() 266 | batch_user_index = user_ids.cpu().numpy() 267 | rating_pred[self.args.train_matrix[batch_user_index].toarray() > 0] = 0 268 | # reference: https://stackoverflow.com/a/23734295, https://stackoverflow.com/a/20104162 269 | # argpartition 时间复杂度O(n) argsort O(nlogn) 只会做 270 | # 加负号"-"表示取大的值 271 | ind = np.argpartition(rating_pred, -20)[:, -20:] 272 | # 根据返回的下标 从对应维度分别取对应的值 得到每行topk的子表 273 | arr_ind = rating_pred[np.arange(len(rating_pred))[:, None], ind] 274 | # 对子表进行排序 得到从大到小的顺序 275 | arr_ind_argsort = np.argsort(arr_ind)[np.arange(len(rating_pred)), ::-1] 276 | # 再取一次 从ind中取回 原来的下标 277 | batch_pred_list = ind[np.arange(len(rating_pred))[:, None], arr_ind_argsort] 278 | 279 | if i == 0: 280 | pred_list = batch_pred_list 281 | answer_list = answers.cpu().data.numpy() 282 | else: 283 | pred_list = np.append(pred_list, batch_pred_list, axis=0) 284 | answer_list = np.append(answer_list, answers.cpu().data.numpy(), axis=0) 285 | return self.get_full_sort_score(epoch, answer_list, pred_list) 286 | 287 | else: 288 | for i, batch in rec_data_iter: 289 | # 0. batch_data will be sent into the device(GPU or cpu) 290 | batch = tuple(t.to(self.device) for t in batch) 291 | user_ids, input_ids, target_pos, target_neg, answers, sample_negs = batch 292 | recommend_output = self.model.finetune(input_ids) 293 | test_neg_items = torch.cat((answers, sample_negs), -1) 294 | recommend_output = recommend_output[:, -1, :] 295 | 296 | test_logits = self.predict_sample(recommend_output, test_neg_items) 297 | test_logits = test_logits.cpu().detach().numpy().copy() 298 | if i == 0: 299 | pred_list = test_logits 300 | else: 301 | pred_list = np.append(pred_list, test_logits, axis=0) 302 | 303 | return self.get_sample_scores(epoch, pred_list) 304 | -------------------------------------------------------------------------------- /utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # @Time : 2020/3/30 11:06 3 | # @Author : Hui Wang 4 | 5 | import numpy as np 6 | import math 7 | import random 8 | import os 9 | import json 10 | import pickle 11 | from scipy.sparse import csr_matrix 12 | 13 | import torch 14 | import torch.nn.functional as F 15 | 16 | def set_seed(seed): 17 | random.seed(seed) 18 | os.environ['PYTHONHASHSEED'] = str(seed) 19 | np.random.seed(seed) 20 | torch.manual_seed(seed) 21 | torch.cuda.manual_seed(seed) 22 | torch.cuda.manual_seed_all(seed) 23 | # some cudnn methods can be random even after fixing the seed 24 | # unless you tell it to be deterministic 25 | torch.backends.cudnn.deterministic = True 26 | 27 | def check_path(path): 28 | if not os.path.exists(path): 29 | os.makedirs(path) 30 | print(f'{path} created') 31 | 32 | def neg_sample(item_set, item_size): # 前闭后闭 33 | item = random.randint(1, item_size - 1) 34 | while item in item_set: 35 | item = random.randint(1, item_size - 1) 36 | return item 37 | 38 | class EarlyStopping: 39 | """Early stops the training if validation loss doesn't improve after a given patience.""" 40 | def __init__(self, checkpoint_path, patience=7, verbose=False, delta=0): 41 | """ 42 | Args: 43 | patience (int): How long to wait after last time validation loss improved. 44 | Default: 7 45 | verbose (bool): If True, prints a message for each validation loss improvement. 46 | Default: False 47 | delta (float): Minimum change in the monitored quantity to qualify as an improvement. 48 | Default: 0 49 | """ 50 | self.checkpoint_path = checkpoint_path 51 | self.patience = patience 52 | self.verbose = verbose 53 | self.counter = 0 54 | self.best_score = None 55 | self.early_stop = False 56 | self.delta = delta 57 | 58 | def compare(self, score): 59 | for i in range(len(score)): 60 | # 有一个指标增加了就认为是还在涨 61 | if score[i] > self.best_score[i]+self.delta: 62 | return False 63 | return True 64 | 65 | def __call__(self, score, model): 66 | # score HIT@10 NDCG@10 67 | 68 | if self.best_score is None: 69 | self.best_score = score 70 | self.score_min = np.array([0]*len(score)) 71 | self.save_checkpoint(score, model) 72 | elif self.compare(score): 73 | self.counter += 1 74 | print(f'EarlyStopping counter: {self.counter} out of {self.patience}') 75 | if self.counter >= self.patience: 76 | self.early_stop = True 77 | else: 78 | self.best_score = score 79 | self.save_checkpoint(score, model) 80 | self.counter = 0 81 | 82 | def save_checkpoint(self, score, model): 83 | '''Saves model when validation loss decrease.''' 84 | if self.verbose: 85 | # ({self.score_min:.6f} --> {score:.6f}) # 这里如果是一个值的话输出才不会有问题 86 | print(f'Validation score increased. Saving model ...') 87 | torch.save(model.state_dict(), self.checkpoint_path) 88 | self.score_min = score 89 | 90 | def kmax_pooling(x, dim, k): 91 | index = x.topk(k, dim=dim)[1].sort(dim=dim)[0] 92 | return x.gather(dim, index).squeeze(dim) 93 | 94 | def avg_pooling(x, dim): 95 | return x.sum(dim=dim)/x.size(dim) 96 | 97 | 98 | def generate_rating_matrix_valid(user_seq, num_users, num_items): 99 | # three lists are used to construct sparse matrix 100 | row = [] 101 | col = [] 102 | data = [] 103 | for user_id, item_list in enumerate(user_seq): 104 | for item in item_list[:-2]: # 105 | row.append(user_id) 106 | col.append(item) 107 | data.append(1) 108 | 109 | row = np.array(row) 110 | col = np.array(col) 111 | data = np.array(data) 112 | rating_matrix = csr_matrix((data, (row, col)), shape=(num_users, num_items)) 113 | 114 | return rating_matrix 115 | 116 | def generate_rating_matrix_test(user_seq, num_users, num_items): 117 | # three lists are used to construct sparse matrix 118 | row = [] 119 | col = [] 120 | data = [] 121 | for user_id, item_list in enumerate(user_seq): 122 | for item in item_list[:-1]: # 123 | row.append(user_id) 124 | col.append(item) 125 | data.append(1) 126 | 127 | row = np.array(row) 128 | col = np.array(col) 129 | data = np.array(data) 130 | rating_matrix = csr_matrix((data, (row, col)), shape=(num_users, num_items)) 131 | 132 | return rating_matrix 133 | 134 | def get_user_seqs(data_file): 135 | lines = open(data_file).readlines() 136 | user_seq = [] 137 | item_set = set() 138 | for line in lines: 139 | user, items = line.strip().split(' ', 1) 140 | items = items.split(' ') 141 | items = [int(item) for item in items] 142 | user_seq.append(items) 143 | item_set = item_set | set(items) 144 | max_item = max(item_set) 145 | 146 | num_users = len(lines) 147 | num_items = max_item + 2 148 | 149 | valid_rating_matrix = generate_rating_matrix_valid(user_seq, num_users, num_items) 150 | test_rating_matrix = generate_rating_matrix_test(user_seq, num_users, num_items) 151 | return user_seq, max_item, valid_rating_matrix, test_rating_matrix 152 | 153 | def get_user_seqs_long(data_file): 154 | lines = open(data_file).readlines() 155 | user_seq = [] 156 | long_sequence = [] 157 | item_set = set() 158 | for line in lines: 159 | user, items = line.strip().split(' ', 1) 160 | items = items.split(' ') 161 | items = [int(item) for item in items] 162 | long_sequence.extend(items) # 后面的都是采的负例 163 | user_seq.append(items) 164 | item_set = item_set | set(items) 165 | max_item = max(item_set) 166 | 167 | return user_seq, max_item, long_sequence 168 | 169 | def get_user_seqs_and_sample(data_file, sample_file): 170 | lines = open(data_file).readlines() 171 | user_seq = [] 172 | item_set = set() 173 | for line in lines: 174 | user, items = line.strip().split(' ', 1) 175 | items = items.split(' ') 176 | items = [int(item) for item in items] 177 | user_seq.append(items) 178 | item_set = item_set | set(items) 179 | max_item = max(item_set) 180 | 181 | lines = open(sample_file).readlines() 182 | sample_seq = [] 183 | for line in lines: 184 | user, items = line.strip().split(' ', 1) 185 | items = items.split(' ') 186 | items = [int(item) for item in items] 187 | sample_seq.append(items) 188 | 189 | assert len(user_seq) == len(sample_seq) 190 | 191 | return user_seq, max_item, sample_seq 192 | 193 | def get_item2attribute_json(data_file): 194 | item2attribute = json.loads(open(data_file).readline()) 195 | attribute_set = set() 196 | for item, attributes in item2attribute.items(): 197 | attribute_set = attribute_set | set(attributes) 198 | attribute_size = max(attribute_set) # 331 199 | return item2attribute, attribute_size 200 | 201 | def get_metric(pred_list, topk=10): 202 | NDCG = 0.0 203 | HIT = 0.0 204 | MRR = 0.0 205 | # [batch] the answer's rank 206 | for rank in pred_list: 207 | MRR += 1.0 / (rank + 1.0) 208 | if rank < topk: 209 | NDCG += 1.0 / np.log2(rank + 2.0) 210 | HIT += 1.0 211 | return HIT /len(pred_list), NDCG /len(pred_list), MRR /len(pred_list) 212 | 213 | def precision_at_k_per_sample(actual, predicted, topk): 214 | num_hits = 0 215 | for place in predicted: 216 | if place in actual: 217 | num_hits += 1 218 | return num_hits / (topk + 0.0) 219 | 220 | def precision_at_k(actual, predicted, topk): 221 | sum_precision = 0.0 222 | num_users = len(predicted) 223 | for i in range(num_users): 224 | act_set = set(actual[i]) 225 | pred_set = set(predicted[i][:topk]) 226 | sum_precision += len(act_set & pred_set) / float(topk) 227 | 228 | return sum_precision / num_users 229 | 230 | def recall_at_k(actual, predicted, topk): 231 | sum_recall = 0.0 232 | num_users = len(predicted) 233 | true_users = 0 234 | for i in range(num_users): 235 | act_set = set(actual[i]) 236 | pred_set = set(predicted[i][:topk]) 237 | if len(act_set) != 0: 238 | sum_recall += len(act_set & pred_set) / float(len(act_set)) 239 | true_users += 1 240 | return sum_recall / true_users 241 | 242 | 243 | def apk(actual, predicted, k=10): 244 | """ 245 | Computes the average precision at k. 246 | This function computes the average precision at k between two lists of 247 | items. 248 | Parameters 249 | ---------- 250 | actual : list 251 | A list of elements that are to be predicted (order doesn't matter) 252 | predicted : list 253 | A list of predicted elements (order does matter) 254 | k : int, optional 255 | The maximum number of predicted elements 256 | Returns 257 | ------- 258 | score : double 259 | The average precision at k over the input lists 260 | """ 261 | if len(predicted)>k: 262 | predicted = predicted[:k] 263 | 264 | score = 0.0 265 | num_hits = 0.0 266 | 267 | for i,p in enumerate(predicted): 268 | if p in actual and p not in predicted[:i]: 269 | num_hits += 1.0 270 | score += num_hits / (i+1.0) 271 | 272 | if not actual: 273 | return 0.0 274 | 275 | return score / min(len(actual), k) 276 | 277 | 278 | def mapk(actual, predicted, k=10): 279 | """ 280 | Computes the mean average precision at k. 281 | This function computes the mean average prescision at k between two lists 282 | of lists of items. 283 | Parameters 284 | ---------- 285 | actual : list 286 | A list of lists of elements that are to be predicted 287 | (order doesn't matter in the lists) 288 | predicted : list 289 | A list of lists of predicted elements 290 | (order matters in the lists) 291 | k : int, optional 292 | The maximum number of predicted elements 293 | Returns 294 | ------- 295 | score : double 296 | The mean average precision at k over the input lists 297 | """ 298 | return np.mean([apk(a, p, k) for a, p in zip(actual, predicted)]) 299 | 300 | def ndcg_k(actual, predicted, topk): 301 | res = 0 302 | for user_id in range(len(actual)): 303 | k = min(topk, len(actual[user_id])) 304 | idcg = idcg_k(k) 305 | dcg_k = sum([int(predicted[user_id][j] in 306 | set(actual[user_id])) / math.log(j+2, 2) for j in range(topk)]) 307 | res += dcg_k / idcg 308 | return res / float(len(actual)) 309 | 310 | 311 | # Calculates the ideal discounted cumulative gain at k 312 | def idcg_k(k): 313 | res = sum([1.0/math.log(i+2, 2) for i in range(k)]) 314 | if not res: 315 | return 1.0 316 | else: 317 | return res --------------------------------------------------------------------------------