diff --git a/recbole/config/configurator.py b/recbole/config/configurator.py index e430389a4..9d312d5c6 100644 --- a/recbole/config/configurator.py +++ b/recbole/config/configurator.py @@ -433,9 +433,9 @@ def _set_default_parameters(self): ) for op_args in default_train_neg_sample_args: if op_args not in self.final_config_dict["train_neg_sample_args"]: - self.final_config_dict["train_neg_sample_args"][ - op_args - ] = default_train_neg_sample_args[op_args] + self.final_config_dict["train_neg_sample_args"][op_args] = ( + default_train_neg_sample_args[op_args] + ) # eval_args checking default_eval_args = { diff --git a/recbole/data/dataset/customized_dataset.py b/recbole/data/dataset/customized_dataset.py index 1e900e5ed..c8b911c55 100644 --- a/recbole/data/dataset/customized_dataset.py +++ b/recbole/data/dataset/customized_dataset.py @@ -146,9 +146,9 @@ def data_augmentation(self): for i, (index, length) in enumerate( zip(item_list_index, item_list_length) ): - new_dict[self.neg_item_list_field][i][ - :length - ] = self.neg_item_list[index] + new_dict[self.neg_item_list_field][i][:length] = ( + self.neg_item_list[index] + ) new_data.update(Interaction(new_dict)) self.inter_feat = new_data diff --git a/recbole/data/dataset/dataset.py b/recbole/data/dataset/dataset.py index c151abaa1..35fce89c6 100644 --- a/recbole/data/dataset/dataset.py +++ b/recbole/data/dataset/dataset.py @@ -651,9 +651,9 @@ def _fill_nan(self): else: dtype = np.int64 if ftype == FeatureType.TOKEN_SEQ else np.float feat[field] = feat[field].apply( - lambda x: np.array([], dtype=dtype) - if isinstance(x, float) - else x + lambda x: ( + np.array([], dtype=dtype) if isinstance(x, float) else x + ) ) def _normalize(self): diff --git a/recbole/data/transform.py b/recbole/data/transform.py index 225ea747b..cd3fb9210 100644 --- a/recbole/data/transform.py +++ b/recbole/data/transform.py @@ -289,9 +289,9 @@ def __call__(self, dataset, interaction): shuffle_index = list(range(reorder_begin, reorder_begin + reorder_len)) random.shuffle(shuffle_index) - reorder_item_seq[ - reorder_begin : reorder_begin + reorder_len - ] = reorder_item_seq[shuffle_index] + reorder_item_seq[reorder_begin : reorder_begin + reorder_len] = ( + reorder_item_seq[shuffle_index] + ) reorder_seq_list.append( torch.tensor(reorder_item_seq, dtype=torch.long, device=device) diff --git a/recbole/evaluator/metrics.py b/recbole/evaluator/metrics.py index ceff7b37e..4f60a31a0 100644 --- a/recbole/evaluator/metrics.py +++ b/recbole/evaluator/metrics.py @@ -253,6 +253,7 @@ class GAUC(AbstractMetric): :math:`rank_i` is the descending rank of the i-th items in :math:`R(u)`. """ + metric_type = EvaluatorType.RANKING metric_need = ["rec.meanrank"] @@ -393,6 +394,7 @@ class MAE(LossMetric): :math:`|S|` represents the number of pairs in :math:`S`. """ + smaller = True def __init__(self, config): @@ -413,6 +415,7 @@ class RMSE(LossMetric): .. math:: \mathrm{RMSE} = \sqrt{\frac{1}{|{S}|} \sum_{(u, i) \in {S}}(\hat{r}_{u i}-r_{u i})^{2}} """ + smaller = True def __init__(self, config): @@ -434,6 +437,7 @@ class LogLoss(LossMetric): .. math:: LogLoss = \frac{1}{|S|} \sum_{(u,i) \in S}(-((r_{u i} \ \log{\hat{r}_{u i}}) + {(1 - r_{u i})}\ \log{(1 - \hat{r}_{u i})})) """ + smaller = True def __init__(self, config): @@ -461,6 +465,7 @@ class ItemCoverage(AbstractMetric): .. math:: \mathrm{Coverage@K}=\frac{\left| \bigcup_{u \in U} \hat{R}(u) \right|}{|I|} """ + metric_type = EvaluatorType.RANKING metric_need = ["rec.items", "data.num_items"] @@ -509,6 +514,7 @@ class AveragePopularity(AbstractMetric): :math:`\phi(i)` is the number of interaction of item i in training data. """ + metric_type = EvaluatorType.RANKING smaller = True metric_need = ["rec.items", "data.count_items"] @@ -582,6 +588,7 @@ class ShannonEntropy(AbstractMetric): :math:`p(i)` is the probability of recommending item i which is the number of item i in recommended list over all items. """ + metric_type = EvaluatorType.RANKING metric_need = ["rec.items"] @@ -637,6 +644,7 @@ class GiniIndex(AbstractMetric): :math:`P{(i)}` represents the number of times all items appearing in the recommended list, which is indexed in non-decreasing order (P_{(i)} \leq P_{(i+1)}). """ + metric_type = EvaluatorType.RANKING smaller = True metric_need = ["rec.items", "data.num_items"] @@ -699,6 +707,7 @@ class TailPercentage(AbstractMetric): If you want to use this metric, please set the parameter 'tail_ratio' in the config which can be an integer or a float in (0,1]. Otherwise it will default to 0.1. """ + metric_type = EvaluatorType.RANKING metric_need = ["rec.items", "data.count_items"] diff --git a/recbole/model/exlib_recommender/lightgbm.py b/recbole/model/exlib_recommender/lightgbm.py index 1bc64e6f3..d2c32dd00 100644 --- a/recbole/model/exlib_recommender/lightgbm.py +++ b/recbole/model/exlib_recommender/lightgbm.py @@ -14,6 +14,7 @@ class LightGBM(lgb.Booster): r"""LightGBM is inherited from lgb.Booster""" + type = ModelType.DECISIONTREE input_type = InputType.POINTWISE diff --git a/recbole/model/exlib_recommender/xgboost.py b/recbole/model/exlib_recommender/xgboost.py index 8bdda60e4..a2857313d 100644 --- a/recbole/model/exlib_recommender/xgboost.py +++ b/recbole/model/exlib_recommender/xgboost.py @@ -14,6 +14,7 @@ class XGBoost(xgb.Booster): r"""XGBoost is inherited from xgb.Booster""" + type = ModelType.DECISIONTREE input_type = InputType.POINTWISE diff --git a/recbole/model/general_recommender/admmslim.py b/recbole/model/general_recommender/admmslim.py index 31aa710c1..f741b9df8 100644 --- a/recbole/model/general_recommender/admmslim.py +++ b/recbole/model/general_recommender/admmslim.py @@ -111,7 +111,7 @@ def predict(self, interaction): .flatten() ) - return add_noise(torch.from_numpy(r)) + return add_noise(torch.from_numpy(r)).to(self.device) def full_sort_predict(self, interaction): user = interaction[self.USER_ID].cpu().numpy() diff --git a/recbole/model/general_recommender/bpr.py b/recbole/model/general_recommender/bpr.py index 4ab37be69..837dff175 100644 --- a/recbole/model/general_recommender/bpr.py +++ b/recbole/model/general_recommender/bpr.py @@ -26,6 +26,7 @@ class BPR(GeneralRecommender): r"""BPR is a basic matrix factorization model that be trained in the pairwise way.""" + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/cdae.py b/recbole/model/general_recommender/cdae.py index d12cf12c4..b1fd3b0ac 100644 --- a/recbole/model/general_recommender/cdae.py +++ b/recbole/model/general_recommender/cdae.py @@ -26,6 +26,7 @@ class CDAE(GeneralRecommender, AutoEncoderMixin): for top-N recommendation that utilizes the idea of Denoising Auto-Encoders. We implement the the CDAE model with only user dataloader. """ + input_type = InputType.POINTWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/convncf.py b/recbole/model/general_recommender/convncf.py index fc30e730a..f3be318be 100644 --- a/recbole/model/general_recommender/convncf.py +++ b/recbole/model/general_recommender/convncf.py @@ -56,6 +56,7 @@ class ConvNCF(GeneralRecommender): We carefully design the data interface and use sparse tensor to train and test efficiently. We implement the model following the original author with a pairwise training mode. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/dgcf.py b/recbole/model/general_recommender/dgcf.py index a20b670b7..ad4b7870f 100644 --- a/recbole/model/general_recommender/dgcf.py +++ b/recbole/model/general_recommender/dgcf.py @@ -59,6 +59,7 @@ class DGCF(GeneralRecommender): we carefully design the data interface and use sparse tensor to train and test efficiently. We implement the model following the original author with a pairwise training mode. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/diffrec.py b/recbole/model/general_recommender/diffrec.py index ebd8e11d5..82e33a75c 100644 --- a/recbole/model/general_recommender/diffrec.py +++ b/recbole/model/general_recommender/diffrec.py @@ -86,6 +86,7 @@ class DiffRec(GeneralRecommender, AutoEncoderMixin): Note that DiffRec simultaneously ranks all items for each user. We implement the the DiffRec model with only user dataloader. """ + input_type = InputType.LISTWISE def __init__(self, config, dataset): @@ -141,9 +142,9 @@ def __init__(self, config, dataset): self.device ) if self.beta_fixed: - self.betas[ - 0 - ] = 0.00001 # Deep Unsupervised Learning using Noneequilibrium Thermodynamics 2.4.1 + self.betas[0] = ( + 0.00001 # Deep Unsupervised Learning using Noneequilibrium Thermodynamics 2.4.1 + ) # The variance \beta_1 of the first step is fixed to a small constant to prevent overfitting. assert len(self.betas.shape) == 1, "betas must be 1-D" assert ( diff --git a/recbole/model/general_recommender/dmf.py b/recbole/model/general_recommender/dmf.py index 031db1f91..54e74141c 100644 --- a/recbole/model/general_recommender/dmf.py +++ b/recbole/model/general_recommender/dmf.py @@ -37,6 +37,7 @@ class DMF(GeneralRecommender): For a better performance and stability, we replace cosine similarity to inner-product when calculate final score of user's and item's embedding. """ + input_type = InputType.POINTWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/ease.py b/recbole/model/general_recommender/ease.py index d93619546..a56315ea6 100644 --- a/recbole/model/general_recommender/ease.py +++ b/recbole/model/general_recommender/ease.py @@ -18,6 +18,7 @@ class EASE(GeneralRecommender): strengths of auto-encoders and neighborhood-based approaches. """ + input_type = InputType.POINTWISE type = ModelType.TRADITIONAL diff --git a/recbole/model/general_recommender/gcmc.py b/recbole/model/general_recommender/gcmc.py index 805d0b56e..713e58eb7 100644 --- a/recbole/model/general_recommender/gcmc.py +++ b/recbole/model/general_recommender/gcmc.py @@ -48,6 +48,7 @@ class GCMC(GeneralRecommender): We implement the model following the original author with a pairwise training mode. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/itemknn.py b/recbole/model/general_recommender/itemknn.py index b3359df3e..47aef23c3 100644 --- a/recbole/model/general_recommender/itemknn.py +++ b/recbole/model/general_recommender/itemknn.py @@ -161,6 +161,7 @@ def compute_similarity(self, method, block_size=100): class ItemKNN(GeneralRecommender): r"""ItemKNN is a basic model that compute item similarity with the interaction matrix.""" + input_type = InputType.POINTWISE type = ModelType.TRADITIONAL diff --git a/recbole/model/general_recommender/lightgcn.py b/recbole/model/general_recommender/lightgcn.py index de9d9dc14..4844a40d1 100644 --- a/recbole/model/general_recommender/lightgcn.py +++ b/recbole/model/general_recommender/lightgcn.py @@ -39,6 +39,7 @@ class LightGCN(GeneralRecommender): We implement the model following the original author with a pairwise training mode. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/line.py b/recbole/model/general_recommender/line.py index ae9b44d0c..91d0c819c 100644 --- a/recbole/model/general_recommender/line.py +++ b/recbole/model/general_recommender/line.py @@ -37,6 +37,7 @@ class LINE(GeneralRecommender): We implement the model to train users and items embedding for recommendation. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/macridvae.py b/recbole/model/general_recommender/macridvae.py index 09e932afc..f1d8bd14b 100644 --- a/recbole/model/general_recommender/macridvae.py +++ b/recbole/model/general_recommender/macridvae.py @@ -34,6 +34,7 @@ class MacridVAE(GeneralRecommender, AutoEncoderMixin): We implement the model following the original author. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/multidae.py b/recbole/model/general_recommender/multidae.py index 4f2043e56..354589682 100644 --- a/recbole/model/general_recommender/multidae.py +++ b/recbole/model/general_recommender/multidae.py @@ -26,6 +26,7 @@ class MultiDAE(GeneralRecommender, AutoEncoderMixin): We implement the the MultiDAE model with only user dataloader. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/multivae.py b/recbole/model/general_recommender/multivae.py index f04adba82..acc20c40f 100644 --- a/recbole/model/general_recommender/multivae.py +++ b/recbole/model/general_recommender/multivae.py @@ -25,6 +25,7 @@ class MultiVAE(GeneralRecommender, AutoEncoderMixin): We implement the MultiVAE model with only user dataloader. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/ncl.py b/recbole/model/general_recommender/ncl.py index 3c298dfa4..03d6ebf0b 100644 --- a/recbole/model/general_recommender/ncl.py +++ b/recbole/model/general_recommender/ncl.py @@ -23,6 +23,7 @@ class NCL(GeneralRecommender): r"""NCL is a neighborhood-enriched contrastive learning paradigm for graph collaborative filtering. Both structural and semantic neighbors are explicitly captured as contrastive learning objects. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/neumf.py b/recbole/model/general_recommender/neumf.py index 29bfbdc76..c6d1cd1e4 100644 --- a/recbole/model/general_recommender/neumf.py +++ b/recbole/model/general_recommender/neumf.py @@ -33,6 +33,7 @@ class NeuMF(GeneralRecommender): Our implementation only contains a rough pretraining function. """ + input_type = InputType.POINTWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/ngcf.py b/recbole/model/general_recommender/ngcf.py index e6e375577..d315b85ba 100644 --- a/recbole/model/general_recommender/ngcf.py +++ b/recbole/model/general_recommender/ngcf.py @@ -36,6 +36,7 @@ class NGCF(GeneralRecommender): r"""NGCF is a model that incorporate GNN for recommendation. We implement the model following the original author with a pairwise training mode. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/nncf.py b/recbole/model/general_recommender/nncf.py index 732be618b..c311d77c8 100644 --- a/recbole/model/general_recommender/nncf.py +++ b/recbole/model/general_recommender/nncf.py @@ -30,6 +30,7 @@ class NNCF(GeneralRecommender): r"""NNCF is an neural network enhanced matrix factorization model which also captures neighborhood information. We implement the NNCF model with three ways to process neighborhood information. """ + input_type = InputType.POINTWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/pop.py b/recbole/model/general_recommender/pop.py index a4d75d39c..0ad9133cd 100644 --- a/recbole/model/general_recommender/pop.py +++ b/recbole/model/general_recommender/pop.py @@ -25,6 +25,7 @@ class Pop(GeneralRecommender): r"""Pop is an fundamental model that always recommend the most popular item.""" + input_type = InputType.POINTWISE type = ModelType.TRADITIONAL diff --git a/recbole/model/general_recommender/ract.py b/recbole/model/general_recommender/ract.py index 42db0da2f..55b18985c 100644 --- a/recbole/model/general_recommender/ract.py +++ b/recbole/model/general_recommender/ract.py @@ -26,6 +26,7 @@ class RaCT(GeneralRecommender, AutoEncoderMixin): We implement the RaCT model with only user dataloader. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/random.py b/recbole/model/general_recommender/random.py index e2b8d2e26..6faa2a51f 100644 --- a/recbole/model/general_recommender/random.py +++ b/recbole/model/general_recommender/random.py @@ -35,7 +35,7 @@ def calculate_loss(self, interaction): return torch.nn.Parameter(torch.zeros(1)) def predict(self, interaction): - return torch.rand(len(interaction)).squeeze(-1) + return torch.rand(len(interaction), device=self.device).squeeze(-1) def full_sort_predict(self, interaction): batch_user_num = interaction[self.USER_ID].shape[0] diff --git a/recbole/model/general_recommender/recvae.py b/recbole/model/general_recommender/recvae.py index c8fd6322b..8cbc7ad01 100644 --- a/recbole/model/general_recommender/recvae.py +++ b/recbole/model/general_recommender/recvae.py @@ -110,6 +110,7 @@ class RecVAE(GeneralRecommender, AutoEncoderMixin): We implement the model following the original author """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/sgl.py b/recbole/model/general_recommender/sgl.py index 01ed4dcc9..917bd971f 100644 --- a/recbole/model/general_recommender/sgl.py +++ b/recbole/model/general_recommender/sgl.py @@ -35,6 +35,7 @@ class SGL(GeneralRecommender): We implement the model following the original author with a pairwise training mode. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/simplex.py b/recbole/model/general_recommender/simplex.py index 9761c5a4d..c47602591 100644 --- a/recbole/model/general_recommender/simplex.py +++ b/recbole/model/general_recommender/simplex.py @@ -34,6 +34,7 @@ class SimpleX(GeneralRecommender): We implement the model following the original author with a pairwise training mode. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/general_recommender/slimelastic.py b/recbole/model/general_recommender/slimelastic.py index 18b4033d0..0c2945107 100644 --- a/recbole/model/general_recommender/slimelastic.py +++ b/recbole/model/general_recommender/slimelastic.py @@ -26,6 +26,7 @@ class SLIMElastic(GeneralRecommender): regularized optimization problem. """ + input_type = InputType.POINTWISE type = ModelType.TRADITIONAL @@ -99,7 +100,7 @@ def predict(self, interaction): (self.interaction_matrix[user, :].multiply(self.item_similarity[:, item].T)) .sum(axis=1) .getA1() - ) + ).to(self.device) return r diff --git a/recbole/model/general_recommender/spectralcf.py b/recbole/model/general_recommender/spectralcf.py index 8c0375546..ae787ee9f 100644 --- a/recbole/model/general_recommender/spectralcf.py +++ b/recbole/model/general_recommender/spectralcf.py @@ -46,6 +46,7 @@ class SpectralCF(GeneralRecommender): For a better stability, we replace :math:`U U^T` with identity matrix :math:`I` and replace :math:`U \Lambda U^T` with laplace matrix :math:`L`. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/knowledge_aware_recommender/kgcn.py b/recbole/model/knowledge_aware_recommender/kgcn.py index 015c3e386..7d1a2675f 100644 --- a/recbole/model/knowledge_aware_recommender/kgcn.py +++ b/recbole/model/knowledge_aware_recommender/kgcn.py @@ -31,6 +31,7 @@ class KGCN(KnowledgeRecommender): as their receptive field, then combine neighborhood information with bias when calculating the representation of a given entity. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): @@ -64,9 +65,11 @@ def __init__(self, config, dataset): for i in range(self.n_iter): self.linear_layers.append( nn.Linear( - self.embedding_size - if not self.aggregator_class == "concat" - else self.embedding_size * 2, + ( + self.embedding_size + if not self.aggregator_class == "concat" + else self.embedding_size * 2 + ), self.embedding_size, ) ) diff --git a/recbole/model/knowledge_aware_recommender/kgnnls.py b/recbole/model/knowledge_aware_recommender/kgnnls.py index d800db886..9ecfa3348 100644 --- a/recbole/model/knowledge_aware_recommender/kgnnls.py +++ b/recbole/model/knowledge_aware_recommender/kgnnls.py @@ -35,6 +35,7 @@ class KGNNLS(KnowledgeRecommender): labels/scores. Label smoothness provides regularization over the edge weights and it is equivalent to a label propagation scheme on a graph. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): @@ -81,9 +82,11 @@ def __init__(self, config, dataset): for i in range(self.n_iter): self.linear_layers.append( nn.Linear( - self.embedding_size - if not self.aggregator_class == "concat" - else self.embedding_size * 2, + ( + self.embedding_size + if not self.aggregator_class == "concat" + else self.embedding_size * 2 + ), self.embedding_size, ) ) diff --git a/recbole/model/knowledge_aware_recommender/ripplenet.py b/recbole/model/knowledge_aware_recommender/ripplenet.py index 3f1170057..c8c30ed86 100644 --- a/recbole/model/knowledge_aware_recommender/ripplenet.py +++ b/recbole/model/knowledge_aware_recommender/ripplenet.py @@ -30,6 +30,7 @@ class RippleNet(KnowledgeRecommender): we carefully design the data interface and use ripple set to train and test efficiently. We just implement the model following the original author with a pointwise training mode. """ + input_type = InputType.POINTWISE def __init__(self, config, dataset): diff --git a/recbole/model/sequential_recommender/dien.py b/recbole/model/sequential_recommender/dien.py index 7a30d604f..b7eee2797 100644 --- a/recbole/model/sequential_recommender/dien.py +++ b/recbole/model/sequential_recommender/dien.py @@ -65,19 +65,23 @@ def __init__(self, config, dataset): self.item_feat = dataset.get_item_feature() num_item_feature = sum( - 1 - if dataset.field2type[field] - not in [FeatureType.FLOAT_SEQ, FeatureType.FLOAT] - or field in config["numerical_features"] - else 0 + ( + 1 + if dataset.field2type[field] + not in [FeatureType.FLOAT_SEQ, FeatureType.FLOAT] + or field in config["numerical_features"] + else 0 + ) for field in self.item_feat.interaction.keys() ) num_user_feature = sum( - 1 - if dataset.field2type[field] - not in [FeatureType.FLOAT_SEQ, FeatureType.FLOAT] - or field in config["numerical_features"] - else 0 + ( + 1 + if dataset.field2type[field] + not in [FeatureType.FLOAT_SEQ, FeatureType.FLOAT] + or field in config["numerical_features"] + else 0 + ) for field in self.user_feat.interaction.keys() ) item_feat_dim = num_item_feature * self.embedding_size diff --git a/recbole/model/sequential_recommender/din.py b/recbole/model/sequential_recommender/din.py index 0e27a591d..820f96645 100644 --- a/recbole/model/sequential_recommender/din.py +++ b/recbole/model/sequential_recommender/din.py @@ -62,11 +62,13 @@ def __init__(self, config, dataset): # self.dnn_list = [(3 * self.num_feature_field['item'] + self.num_feature_field['user']) # * self.embedding_size] + self.mlp_hidden_size num_item_feature = sum( - 1 - if dataset.field2type[field] - not in [FeatureType.FLOAT_SEQ, FeatureType.FLOAT] - or field in config["numerical_features"] - else 0 + ( + 1 + if dataset.field2type[field] + not in [FeatureType.FLOAT_SEQ, FeatureType.FLOAT] + or field in config["numerical_features"] + else 0 + ) for field in self.item_feat.interaction.keys() ) self.dnn_list = [ diff --git a/recbole/model/sequential_recommender/fpmc.py b/recbole/model/sequential_recommender/fpmc.py index 8db3bd711..ac4332ca0 100644 --- a/recbole/model/sequential_recommender/fpmc.py +++ b/recbole/model/sequential_recommender/fpmc.py @@ -36,6 +36,7 @@ class FPMC(SequentialRecommender): For comparison with other models, the loss function used is BPR. """ + input_type = InputType.PAIRWISE def __init__(self, config, dataset): diff --git a/recbole/model/sequential_recommender/sasrecf.py b/recbole/model/sequential_recommender/sasrecf.py index b1755cd44..82dd66c5a 100644 --- a/recbole/model/sequential_recommender/sasrecf.py +++ b/recbole/model/sequential_recommender/sasrecf.py @@ -41,9 +41,11 @@ def __init__(self, config, dataset): self.pooling_mode = config["pooling_mode"] self.device = config["device"] self.num_feature_field = sum( - 1 - if dataset.field2type[field] != FeatureType.FLOAT_SEQ - else dataset.num(field) + ( + 1 + if dataset.field2type[field] != FeatureType.FLOAT_SEQ + else dataset.num(field) + ) for field in config["selected_features"] ) diff --git a/recbole/trainer/hyper_tuning.py b/recbole/trainer/hyper_tuning.py index cc8742fe5..72dc05b4c 100644 --- a/recbole/trainer/hyper_tuning.py +++ b/recbole/trainer/hyper_tuning.py @@ -69,6 +69,7 @@ def _spacesize(space): class ExhaustiveSearchError(Exception): r"""ExhaustiveSearchError""" + pass