Esempio n. 1
0
    def test8_serialization(self):
        opt = BPRMFOption().get_default_option()
        opt.num_iters = 200
        opt.d = 5
        opt.validation = aux.Option({'topk': 10})

        self._test8_serialization(BPRMF, opt)
Esempio n. 2
0
    def test05_validation(self):
        np.random.seed(7)
        opt = BPRMFOption().get_default_option()
        opt.d = 5
        opt.num_workers = 4
        opt.num_iters = 500
        opt.random_seed = 7
        opt.validation = aux.Option({'topk': 10})
        opt.tensorboard = aux.Option({'root': './tb', 'name': 'bpr'})

        self._test5_validation(BPRMF, opt, ndcg=0.03, map=0.02)
Esempio n. 3
0
 def test12_gpu_train_ml_20m(self):
     if not inited_CUBPR:
         return
     opt = BPRMFOption().get_default_option()
     opt.accelerator = True
     opt.d = 100
     opt.verify_neg = False
     opt.num_iters = 30
     opt.evaluation_period = 5
     opt.validation = aux.Option({'topk': 10})
     self._test7_train_ml_20m(BPRMF, opt)
Esempio n. 4
0
    def test11_gpu_validation(self):
        if not inited_CUBPR:
            return
        np.random.seed(7)
        opt = BPRMFOption().get_default_option()
        opt.d = 100
        opt.verify_neg = False
        opt.accelerator = True
        opt.lr = 0.01
        opt.reg_b = 10.0
        opt.num_iters = 500
        opt.evaluation_period = 50
        opt.random_seed = 777
        opt.validation = aux.Option({'topk': 10})
        opt.tensorboard = aux.Option({'root': './tb', 'name': 'bpr'})

        self._test5_validation(BPRMF, opt, ndcg=0.03, map=0.02)
Esempio n. 5
0
    def test07_topk_pool(self):
        set_log_level(2)
        data_opt = self.get_ml100k_mm_opt()
        opt = BPRMFOption().get_default_option()
        opt.d = 20
        opt.num_workers = 1
        model = BPRMF(opt, data_opt=data_opt)
        model.initialize()
        model.train()
        par = ParBPRMF(model)

        pool = np.array([i for i in range(5)], dtype=np.int32)
        model.build_userid_map()
        all_keys = model._idmanager.userids[::][:10]
        naive = model.topk_recommendation(all_keys, topk=10, pool=pool)
        qkeys1, topks1, scores1 = par.topk_recommendation(all_keys, topk=10, pool=pool, repr=True)
        for q, t in zip(qkeys1, topks1):
            self.assertEqual(naive[q], t)
Esempio n. 6
0
    def test03_most_similar(self):
        set_log_level(1)
        data_opt = self.get_ml100k_mm_opt()
        opt = BPRMFOption().get_default_option()
        opt.d = 20
        opt.num_workers = 1
        bpr = BPRMF(opt, data_opt=data_opt)
        bpr.initialize()
        bpr.train()
        bpr.build_itemid_map()
        parbpr = ParBPRMF(bpr)

        all_keys = bpr._idmanager.itemids[::]
        start_t = time.time()
        [bpr.most_similar(k, topk=10) for k in all_keys]
        naive_elapsed = time.time() - start_t

        parbpr.num_workers = 4
        start_t = time.time()
        parbpr.most_similar(all_keys, topk=10, repr=True)
        parbpr_elapsed = time.time() - start_t

        self.assertTrue(naive_elapsed > parbpr_elapsed * 3.0)
Esempio n. 7
0
 def test10_fast_most_similar(self):
     opt = BPRMFOption().get_default_option()
     opt.d = 5
     opt.validation = aux.Option({'topk': 10})
     self._test10_fast_most_similar(BPRMF, opt)
Esempio n. 8
0
 def test4_train(self):
     opt = BPRMFOption().get_default_option()
     opt.d = 5
     self._test4_train(BPRMF, opt)