diff --git a/recbole/config/configurator.py b/recbole/config/configurator.py index 80a3594cd..7e3bc9427 100644 --- a/recbole/config/configurator.py +++ b/recbole/config/configurator.py @@ -198,7 +198,6 @@ def _merge_external_config_dict(self): self.external_config_dict = external_config_dict def _get_model_and_dataset(self, model, dataset): - if model is None: try: model = self.external_config_dict["model"] diff --git a/recbole/data/dataset/dataset.py b/recbole/data/dataset/dataset.py index 7d010e5f8..d0d00673c 100644 --- a/recbole/data/dataset/dataset.py +++ b/recbole/data/dataset/dataset.py @@ -725,7 +725,6 @@ def _discretization(self): dis_info = {} if self.config["discretization"]: - dis_info = self.config["discretization"] for field in dis_info.keys(): diff --git a/recbole/evaluator/collector.py b/recbole/evaluator/collector.py index f50e6ef5f..07a913721 100644 --- a/recbole/evaluator/collector.py +++ b/recbole/evaluator/collector.py @@ -149,7 +149,6 @@ def eval_batch_collect( positive_i(Torch.Tensor): the positive item id for each user. """ if self.register.need("rec.items"): - # get topk _, topk_idx = torch.topk( scores_tensor, max(self.topk), dim=-1 @@ -157,7 +156,6 @@ def eval_batch_collect( self.data_struct.update_tensor("rec.items", topk_idx) if self.register.need("rec.topk"): - _, topk_idx = torch.topk( scores_tensor, max(self.topk), dim=-1 ) # n_users x k @@ -169,7 +167,6 @@ def eval_batch_collect( self.data_struct.update_tensor("rec.topk", result) if self.register.need("rec.meanrank"): - desc_scores, desc_index = torch.sort(scores_tensor, dim=-1, descending=True) # get the index of positive items in the ranking list @@ -188,7 +185,6 @@ def eval_batch_collect( self.data_struct.update_tensor("rec.meanrank", result) if self.register.need("rec.score"): - self.data_struct.update_tensor("rec.score", scores_tensor) if self.register.need("data.label"): diff --git a/recbole/evaluator/register.py b/recbole/evaluator/register.py index 3de9e00b0..0b1c2ba55 100644 --- a/recbole/evaluator/register.py +++ b/recbole/evaluator/register.py @@ -72,7 +72,6 @@ class Register(object): """ def __init__(self, config): - self.config = config self.metrics = [metric.lower() for metric in self.config["metrics"]] self._build_register() diff --git a/recbole/model/context_aware_recommender/fignn.py b/recbole/model/context_aware_recommender/fignn.py index 443387579..9cec993d4 100644 --- a/recbole/model/context_aware_recommender/fignn.py +++ b/recbole/model/context_aware_recommender/fignn.py @@ -105,7 +105,6 @@ def __init__(self, config, dataset): self.apply(self._init_weights) def fignn_layer(self, in_feature): - emb_feature = self.att_embedding(in_feature) emb_feature = self.dropout_layer(emb_feature) # multi-head self-attention network diff --git a/recbole/model/context_aware_recommender/fm.py b/recbole/model/context_aware_recommender/fm.py index 492876422..7fd75c52c 100644 --- a/recbole/model/context_aware_recommender/fm.py +++ b/recbole/model/context_aware_recommender/fm.py @@ -27,7 +27,6 @@ class FM(ContextRecommender): """Factorization Machine considers the second-order interaction with features to predict the final score.""" def __init__(self, config, dataset): - super(FM, self).__init__(config, dataset) # define layers and loss diff --git a/recbole/model/general_recommender/dmf.py b/recbole/model/general_recommender/dmf.py index a07cc37ad..031db1f91 100644 --- a/recbole/model/general_recommender/dmf.py +++ b/recbole/model/general_recommender/dmf.py @@ -130,7 +130,6 @@ def _init_weights(self, module): normal_(module.weight.data, 0, 0.01) def forward(self, user, item): - user = self.get_user_embedding(user) # Following lines construct tensor of shape [B,n_users] using the tensor of shape [B,H] diff --git a/recbole/model/general_recommender/gcmc.py b/recbole/model/general_recommender/gcmc.py index f52914686..805d0b56e 100644 --- a/recbole/model/general_recommender/gcmc.py +++ b/recbole/model/general_recommender/gcmc.py @@ -432,7 +432,7 @@ def forward(self, user_X, item_X): v_hidden = self.dropout(v_hidden) u_hidden = self.dense_layer_u(u_hidden) - v_hidden = self.dense_layer_u(v_hidden) + v_hidden = self.dense_layer_v(v_hidden) u_outputs = self.dense_activate(u_hidden) v_outputs = self.dense_activate(v_hidden) diff --git a/recbole/model/general_recommender/itemknn.py b/recbole/model/general_recommender/itemknn.py index 1e6b5d55e..b3359df3e 100644 --- a/recbole/model/general_recommender/itemknn.py +++ b/recbole/model/general_recommender/itemknn.py @@ -82,7 +82,6 @@ def compute_similarity(self, method, block_size=100): # Compute all similarities using vectorization while start_block < end_local: - end_block = min(start_block + block_size, end_local) this_block_size = end_block - start_block diff --git a/recbole/model/general_recommender/line.py b/recbole/model/general_recommender/line.py index 97da90f6a..ae9b44d0c 100644 --- a/recbole/model/general_recommender/line.py +++ b/recbole/model/general_recommender/line.py @@ -79,7 +79,6 @@ def get_used_ids(self): return cur def sampler(self, key_ids): - key_ids = np.array(key_ids.cpu()) key_num = len(key_ids) total_num = key_num @@ -121,14 +120,12 @@ def get_user_id_list(self): return np.arange(1, self.n_users) def forward(self, h, t): - h_embedding = self.user_embedding(h) t_embedding = self.item_embedding(t) return torch.sum(h_embedding.mul(t_embedding), dim=1) def context_forward(self, h, t, field): - if field == "uu": h_embedding = self.user_embedding(h) t_embedding = self.item_context_embedding(t) @@ -139,7 +136,6 @@ def context_forward(self, h, t, field): return torch.sum(h_embedding.mul(t_embedding), dim=1) def calculate_loss(self, interaction): - user = interaction[self.USER_ID] pos_item = interaction[self.ITEM_ID] neg_item = interaction[self.NEG_ITEM_ID] @@ -178,7 +174,6 @@ def calculate_loss(self, interaction): ) def predict(self, interaction): - user = interaction[self.USER_ID] item = interaction[self.ITEM_ID] diff --git a/recbole/model/general_recommender/macridvae.py b/recbole/model/general_recommender/macridvae.py index 258642584..09e932afc 100644 --- a/recbole/model/general_recommender/macridvae.py +++ b/recbole/model/general_recommender/macridvae.py @@ -82,7 +82,6 @@ def reparameterize(self, mu, logvar): return mu def forward(self, rating_matrix): - cores = F.normalize(self.k_embedding.weight, dim=1) items = F.normalize(self.item_embedding.weight, dim=1) @@ -127,7 +126,6 @@ def forward(self, rating_matrix): return logits, mulist, logvarlist def calculate_loss(self, interaction): - user = interaction[self.USER_ID] rating_matrix = self.get_rating_matrix(user) @@ -169,7 +167,6 @@ def reg_loss(self): return loss_1 + loss_2 + loss_3 def predict(self, interaction): - user = interaction[self.USER_ID] item = interaction[self.ITEM_ID] diff --git a/recbole/model/general_recommender/multidae.py b/recbole/model/general_recommender/multidae.py index 0c4d0d33e..4f2043e56 100644 --- a/recbole/model/general_recommender/multidae.py +++ b/recbole/model/general_recommender/multidae.py @@ -55,7 +55,6 @@ def mlp_layers(self, layer_dims): return nn.Sequential(*mlp_modules) def forward(self, rating_matrix): - h = F.normalize(rating_matrix) h = F.dropout(h, self.drop_out, training=self.training) @@ -64,7 +63,6 @@ def forward(self, rating_matrix): return self.decoder(h) def calculate_loss(self, interaction): - user = interaction[self.USER_ID] rating_matrix = self.get_rating_matrix(user) @@ -77,7 +75,6 @@ def calculate_loss(self, interaction): return ce_loss def predict(self, interaction): - user = interaction[self.USER_ID] item = interaction[self.ITEM_ID] @@ -88,7 +85,6 @@ def predict(self, interaction): return scores[[torch.arange(len(item)).to(self.device), item]] def full_sort_predict(self, interaction): - user = interaction[self.USER_ID] rating_matrix = self.get_rating_matrix(user) diff --git a/recbole/model/general_recommender/multivae.py b/recbole/model/general_recommender/multivae.py index b12273046..f04adba82 100644 --- a/recbole/model/general_recommender/multivae.py +++ b/recbole/model/general_recommender/multivae.py @@ -68,7 +68,6 @@ def reparameterize(self, mu, logvar): return mu def forward(self, rating_matrix): - h = F.normalize(rating_matrix) h = F.dropout(h, self.drop_out, training=self.training) @@ -83,7 +82,6 @@ def forward(self, rating_matrix): return z, mu, logvar def calculate_loss(self, interaction): - user = interaction[self.USER_ID] rating_matrix = self.get_rating_matrix(user) @@ -108,7 +106,6 @@ def calculate_loss(self, interaction): return ce_loss + kl_loss def predict(self, interaction): - user = interaction[self.USER_ID] item = interaction[self.ITEM_ID] diff --git a/recbole/model/general_recommender/ngcf.py b/recbole/model/general_recommender/ngcf.py index e98d7dad4..e6e375577 100644 --- a/recbole/model/general_recommender/ngcf.py +++ b/recbole/model/general_recommender/ngcf.py @@ -146,7 +146,6 @@ def get_ego_embeddings(self): return ego_embeddings def forward(self): - A_hat = ( self.sparse_dropout(self.norm_adj_matrix) if self.node_dropout != 0 @@ -195,7 +194,6 @@ def calculate_loss(self, interaction): return mf_loss + self.reg_weight * reg_loss def predict(self, interaction): - user = interaction[self.USER_ID] item = interaction[self.ITEM_ID] diff --git a/recbole/model/general_recommender/ract.py b/recbole/model/general_recommender/ract.py index d4dc50b71..42db0da2f 100644 --- a/recbole/model/general_recommender/ract.py +++ b/recbole/model/general_recommender/ract.py @@ -103,7 +103,6 @@ def reparameterize(self, mu, logvar): return mu def forward(self, rating_matrix): - t = F.normalize(rating_matrix) h = F.dropout(t, self.drop_out, training=self.training) * (1 - self.drop_out) @@ -127,7 +126,6 @@ def forward(self, rating_matrix): return z, mu, logvar def calculate_actor_loss(self, interaction): - user = interaction[self.USER_ID] rating_matrix = self.get_rating_matrix(user) @@ -211,7 +209,6 @@ def calculate_ac_loss(self, interaction): return -1 * y def calculate_loss(self, interaction): - # actor_pretrain if self.train_stage == "actor_pretrain": return self.calculate_actor_loss(interaction).mean() @@ -223,7 +220,6 @@ def calculate_loss(self, interaction): return self.calculate_ac_loss(interaction).mean() def predict(self, interaction): - user = interaction[self.USER_ID] item = interaction[self.ITEM_ID] diff --git a/recbole/model/knowledge_aware_recommender/mcclk.py b/recbole/model/knowledge_aware_recommender/mcclk.py index 15bc47649..d39e28d3e 100644 --- a/recbole/model/knowledge_aware_recommender/mcclk.py +++ b/recbole/model/knowledge_aware_recommender/mcclk.py @@ -38,7 +38,6 @@ def __init__(self, item_only=False, attention=True): def forward( self, entity_emb, user_emb, relation_emb, edge_index, edge_type, inter_matrix ): - from torch_scatter import scatter_softmax, scatter_mean n_entities = entity_emb.shape[0] @@ -169,7 +168,6 @@ def edge_sampling(self, edge_index, edge_type, rate=0.5): return edge_index[:, random_indices], edge_type[random_indices] def forward(self, user_emb, entity_emb): - # node dropout if self.node_dropout_rate > 0.0: edge_index, edge_type = self.edge_sampling( @@ -263,7 +261,6 @@ def build_adj(self, context, topk): return L_norm def _build_graph_separately(self, entity_emb): - # node dropout if self.node_dropout_rate > 0.0: edge_index, edge_type = self.edge_sampling( @@ -455,7 +452,6 @@ def get_edges(self, graph): return index.to(self.device), type.to(self.device) def forward(self): - user_emb = self.user_embedding.weight entity_emb = self.entity_embedding.weight # Construct a k-Nearest-Neighbor item-item semantic graph and Structural View Encoder @@ -503,7 +499,6 @@ def sim(self, z1: torch.Tensor, z2: torch.Tensor): return torch.mm(z1, z2.t()) def calculate_loss(self, interaction): - if self.restore_user_e is not None or self.restore_item_e is not None: self.restore_user_e, self.restore_item_e = None, None diff --git a/recbole/model/layers.py b/recbole/model/layers.py index 738fcc4fd..6defc637b 100644 --- a/recbole/model/layers.py +++ b/recbole/model/layers.py @@ -596,7 +596,6 @@ def __init__( hidden_act="gelu", layer_norm_eps=1e-12, ): - super(TransformerEncoder, self).__init__() layer = TransformerLayer( n_heads, @@ -825,7 +824,6 @@ def __init__( hidden_act="gelu", layer_norm_eps=1e-12, ): - super(LightTransformerEncoder, self).__init__() layer = LightTransformerLayer( n_heads, @@ -1354,7 +1352,6 @@ class FMFirstOrderLinear(nn.Module): """ def __init__(self, config, dataset, output_dim=1): - super(FMFirstOrderLinear, self).__init__() self.field_names = dataset.fields( source=[ diff --git a/recbole/model/sequential_recommender/dien.py b/recbole/model/sequential_recommender/dien.py index c031d3221..7a30d604f 100644 --- a/recbole/model/sequential_recommender/dien.py +++ b/recbole/model/sequential_recommender/dien.py @@ -123,7 +123,6 @@ def _init_weights(self, module): constant_(module.bias.data, 0) def forward(self, user, item_seq, neg_item_seq, item_seq_len, next_items): - max_length = item_seq.shape[1] # concatenate the history item seq with the target item to get embedding together item_seq_next_item = torch.cat( diff --git a/recbole/model/sequential_recommender/din.py b/recbole/model/sequential_recommender/din.py index 2639f15dc..0e27a591d 100644 --- a/recbole/model/sequential_recommender/din.py +++ b/recbole/model/sequential_recommender/din.py @@ -110,7 +110,6 @@ def _init_weights(self, module): constant_(module.bias.data, 0) def forward(self, user, item_seq, item_seq_len, next_items): - max_length = item_seq.shape[1] # concatenate the history item seq with the target item to get embedding together item_seq_next_item = torch.cat((item_seq, next_items.unsqueeze(1)), dim=-1) diff --git a/recbole/model/sequential_recommender/fossil.py b/recbole/model/sequential_recommender/fossil.py index 42c1031e2..ccd5a7509 100644 --- a/recbole/model/sequential_recommender/fossil.py +++ b/recbole/model/sequential_recommender/fossil.py @@ -92,7 +92,6 @@ def inverse_seq_item_embedding(self, seq_item_embedding, seq_item_len): return short_item_embedding def reg_loss(self, user_embedding, item_embedding, seq_output): - reg_1 = self.reg_weight loss_1 = ( reg_1 * torch.norm(user_embedding, p=2) @@ -103,12 +102,10 @@ def reg_loss(self, user_embedding, item_embedding, seq_output): return loss_1 def init_weights(self, module): - if isinstance(module, nn.Embedding) or isinstance(module, nn.Linear): xavier_normal_(module.weight.data) def forward(self, seq_item, seq_item_len, user): - seq_item_embedding = self.item_embedding(seq_item) high_order_seq_item_embedding = self.inverse_seq_item_embedding( @@ -152,7 +149,6 @@ def get_similarity(self, seq_item_embedding, seq_item_len): return similarity def calculate_loss(self, interaction): - seq_item = interaction[self.ITEM_SEQ] user = interaction[self.USER_ID] seq_item_len = interaction[self.ITEM_SEQ_LEN] @@ -176,7 +172,6 @@ def calculate_loss(self, interaction): return loss + self.reg_loss(user_lambda, pos_items_embedding, seq_output) def predict(self, interaction): - item_seq = interaction[self.ITEM_SEQ] item_seq_len = interaction[self.ITEM_SEQ_LEN] test_item = interaction[self.ITEM_ID] @@ -187,7 +182,6 @@ def predict(self, interaction): return scores def full_sort_predict(self, interaction): - item_seq = interaction[self.ITEM_SEQ] user = interaction[self.USER_ID] item_seq_len = interaction[self.ITEM_SEQ_LEN] diff --git a/recbole/model/sequential_recommender/hgn.py b/recbole/model/sequential_recommender/hgn.py index 7d2c2021d..a89e5beb0 100644 --- a/recbole/model/sequential_recommender/hgn.py +++ b/recbole/model/sequential_recommender/hgn.py @@ -77,7 +77,6 @@ def __init__(self, config, dataset): self.apply(self._init_weights) def reg_loss(self, user_embedding, item_embedding, seq_item_embedding): - reg_1, reg_2 = self.reg_weight loss_1_part_1 = reg_1 * torch.norm(self.w1.weight, p=2) loss_1_part_2 = reg_1 * torch.norm(self.w2.weight, p=2) @@ -158,7 +157,6 @@ def instance_gating(self, user_item, user_embedding): return output def forward(self, seq_item, user): - seq_item_embedding = self.item_embedding(seq_item) user_embedding = self.user_embedding(user) feature_gating = self.feature_gating(seq_item_embedding, user_embedding) @@ -170,7 +168,6 @@ def forward(self, seq_item, user): return user_embedding + instance_gating + item_item def calculate_loss(self, interaction): - seq_item = interaction[self.ITEM_SEQ] seq_item_embedding = self.item_embedding(seq_item) user = interaction[self.USER_ID] @@ -196,7 +193,6 @@ def calculate_loss(self, interaction): ) def predict(self, interaction): - item_seq = interaction[self.ITEM_SEQ] test_item = interaction[self.ITEM_ID] user = interaction[self.USER_ID] @@ -206,7 +202,6 @@ def predict(self, interaction): return scores def full_sort_predict(self, interaction): - item_seq = interaction[self.ITEM_SEQ] user = interaction[self.USER_ID] seq_output = self.forward(item_seq, user) diff --git a/recbole/model/sequential_recommender/hrm.py b/recbole/model/sequential_recommender/hrm.py index 16202a64c..01db57dfe 100644 --- a/recbole/model/sequential_recommender/hrm.py +++ b/recbole/model/sequential_recommender/hrm.py @@ -86,12 +86,10 @@ def inverse_seq_item(self, seq_item, seq_item_len): return seq_item def _init_weights(self, module): - if isinstance(module, nn.Embedding): xavier_normal_(module.weight.data) def forward(self, seq_item, user, seq_item_len): - # seq_item=self.inverse_seq_item(seq_item) seq_item = self.inverse_seq_item(seq_item, seq_item_len) @@ -141,7 +139,6 @@ def forward(self, seq_item, user, seq_item_len): return hybrid_user_embedding def calculate_loss(self, interaction): - seq_item = interaction[self.ITEM_SEQ] seq_item_len = interaction[self.ITEM_SEQ_LEN] user = interaction[self.USER_ID] @@ -163,7 +160,6 @@ def calculate_loss(self, interaction): return loss def predict(self, interaction): - item_seq = interaction[self.ITEM_SEQ] seq_item_len = interaction[self.ITEM_SEQ_LEN] test_item = interaction[self.ITEM_ID] @@ -175,7 +171,6 @@ def predict(self, interaction): return scores def full_sort_predict(self, interaction): - item_seq = interaction[self.ITEM_SEQ] seq_item_len = interaction[self.ITEM_SEQ_LEN] user = interaction[self.USER_ID] diff --git a/recbole/model/sequential_recommender/narm.py b/recbole/model/sequential_recommender/narm.py index 06512a9c8..eedee66e0 100644 --- a/recbole/model/sequential_recommender/narm.py +++ b/recbole/model/sequential_recommender/narm.py @@ -81,7 +81,6 @@ def _init_weights(self, module): constant_(module.bias.data, 0) def forward(self, item_seq, item_seq_len): - item_seq_emb = self.item_embedding(item_seq) item_seq_emb_dropout = self.emb_dropout(item_seq_emb) gru_out, _ = self.gru(item_seq_emb_dropout) diff --git a/recbole/model/sequential_recommender/nextitnet.py b/recbole/model/sequential_recommender/nextitnet.py index 18392ffdc..6021b8aff 100644 --- a/recbole/model/sequential_recommender/nextitnet.py +++ b/recbole/model/sequential_recommender/nextitnet.py @@ -180,7 +180,6 @@ def __init__(self, in_channel, out_channel, kernel_size=3, dilation=None): self.kernel_size = kernel_size def forward(self, x): # x: [batch_size, seq_len, embed_size] - out = F.relu(self.ln1(x)) out = out.permute(0, 2, 1).unsqueeze(2) out = self.conv1(out).squeeze(2).permute(0, 2, 1) diff --git a/recbole/model/sequential_recommender/npe.py b/recbole/model/sequential_recommender/npe.py index fbf4a5242..7642cb6f0 100644 --- a/recbole/model/sequential_recommender/npe.py +++ b/recbole/model/sequential_recommender/npe.py @@ -67,7 +67,6 @@ def _init_weights(self, module): xavier_normal_(module.weight.data) def forward(self, seq_item, user): - user_embedding = self.dropout(self.relu(self.user_embedding(user))) # batch_size * embedding_size seq_item_embedding = self.item_embedding(seq_item).sum(dim=1) @@ -77,7 +76,6 @@ def forward(self, seq_item, user): return user_embedding + seq_item_embedding def calculate_loss(self, interaction): - seq_item = interaction[self.ITEM_SEQ] user = interaction[self.USER_ID] seq_output = self.forward(seq_item, user) @@ -98,7 +96,6 @@ def calculate_loss(self, interaction): return loss def predict(self, interaction): - item_seq = interaction[self.ITEM_SEQ] test_item = interaction[self.ITEM_ID] user = interaction[self.USER_ID] @@ -108,7 +105,6 @@ def predict(self, interaction): return scores def full_sort_predict(self, interaction): - item_seq = interaction[self.ITEM_SEQ] user = interaction[self.USER_ID] seq_output = self.forward(item_seq, user) diff --git a/recbole/model/sequential_recommender/repeatnet.py b/recbole/model/sequential_recommender/repeatnet.py index c03d8f22b..e3506f2e7 100644 --- a/recbole/model/sequential_recommender/repeatnet.py +++ b/recbole/model/sequential_recommender/repeatnet.py @@ -37,7 +37,6 @@ class RepeatNet(SequentialRecommender): input_type = InputType.POINTWISE def __init__(self, config, dataset): - super(RepeatNet, self).__init__(config, dataset) # load the dataset information @@ -81,7 +80,6 @@ def __init__(self, config, dataset): self.apply(self._init_weights) def _init_weights(self, module): - if isinstance(module, nn.Embedding): xavier_normal_(module.weight.data) elif isinstance(module, nn.Linear): @@ -90,7 +88,6 @@ def _init_weights(self, module): constant_(module.bias.data, 0) def forward(self, item_seq, item_seq_len): - batch_seq_item_embedding = self.item_matrix(item_seq) # batch_size * seq_len == embedding ==>> batch_size * seq_len * embedding_size @@ -130,7 +127,6 @@ def forward(self, item_seq, item_seq_len): return prediction def calculate_loss(self, interaction): - item_seq = interaction[self.ITEM_SEQ] item_seq_len = interaction[self.ITEM_SEQ_LEN] pos_item = interaction[self.POS_ITEM_ID] @@ -142,7 +138,6 @@ def calculate_loss(self, interaction): return loss def repeat_explore_loss(self, item_seq, pos_item): - batch_size = item_seq.size(0) repeat, explore = torch.zeros(batch_size).to(self.device), torch.ones( batch_size @@ -163,7 +158,6 @@ def repeat_explore_loss(self, item_seq, pos_item): return (-repeat_loss - explore_loss) / 2 def full_sort_predict(self, interaction): - item_seq = interaction[self.ITEM_SEQ] item_seq_len = interaction[self.ITEM_SEQ_LEN] prediction = self.forward(item_seq, item_seq_len) @@ -171,7 +165,6 @@ def full_sort_predict(self, interaction): return prediction def predict(self, interaction): - item_seq = interaction[self.ITEM_SEQ] test_item = interaction[self.ITEM_ID] item_seq_len = interaction[self.ITEM_SEQ_LEN] diff --git a/recbole/model/sequential_recommender/shan.py b/recbole/model/sequential_recommender/shan.py index 2b51d8a10..cd5bc7029 100644 --- a/recbole/model/sequential_recommender/shan.py +++ b/recbole/model/sequential_recommender/shan.py @@ -30,7 +30,6 @@ class SHAN(SequentialRecommender): """ def __init__(self, config, dataset): - super(SHAN, self).__init__(config, dataset) # load the dataset information @@ -87,7 +86,6 @@ def __init__(self, config, dataset): self.apply(self.init_weights) def reg_loss(self, user_embedding, item_embedding): - reg_1, reg_2 = self.reg_weight loss_1 = reg_1 * torch.norm(self.long_w.weight, p=2) + reg_1 * torch.norm( self.long_short_w.weight, p=2 @@ -116,7 +114,6 @@ def init_weights(self, module): print(module.data) def forward(self, seq_item, user): - seq_item_embedding = self.item_embedding(seq_item) user_embedding = self.user_embedding(user) @@ -150,7 +147,6 @@ def forward(self, seq_item, user): return long_short_item_embedding def calculate_loss(self, interaction): - inverse_seq_item = interaction[self.INVERSE_ITEM_SEQ] user = interaction[self.USER_ID] user_embedding = self.user_embedding(user) @@ -171,7 +167,6 @@ def calculate_loss(self, interaction): return loss + self.reg_loss(user_embedding, pos_items_emb) def predict(self, interaction): - inverse_item_seq = interaction[self.INVERSE_ITEM_SEQ] test_item = interaction[self.ITEM_ID] user = interaction[self.USER_ID] @@ -181,7 +176,6 @@ def predict(self, interaction): return scores def full_sort_predict(self, interaction): - inverse_item_seq = interaction[self.ITEM_SEQ] user = interaction[self.USER_ID] seq_output = self.forward(inverse_item_seq, user) diff --git a/recbole/model/sequential_recommender/srgnn.py b/recbole/model/sequential_recommender/srgnn.py index c9371fa86..b7baab173 100644 --- a/recbole/model/sequential_recommender/srgnn.py +++ b/recbole/model/sequential_recommender/srgnn.py @@ -199,7 +199,6 @@ def _get_slice(self, item_seq): return alias_inputs, A, items, mask def forward(self, item_seq, item_seq_len): - alias_inputs, A, items, mask = self._get_slice(item_seq) hidden = self.item_embedding(items) hidden = self.gnn(A, hidden) diff --git a/recbole/trainer/trainer.py b/recbole/trainer/trainer.py index bab245714..3e729ff31 100644 --- a/recbole/trainer/trainer.py +++ b/recbole/trainer/trainer.py @@ -1334,7 +1334,6 @@ def fit( self.eval_collector.data_collect(train_data) for epoch_idx in range(self.start_epoch, self.epochs): - # only differences from the original trainer if epoch_idx % self.num_m_step == 0: self.logger.info("Running E-step ! ") diff --git a/recbole/utils/utils.py b/recbole/utils/utils.py index f31360a11..d34dbd2ac 100644 --- a/recbole/utils/utils.py +++ b/recbole/utils/utils.py @@ -348,7 +348,6 @@ def dfs_count(module: nn.Module, prefix="\t"): total_ops, total_params = module.total_ops.item(), 0 ret_dict = {} for n, m in module.named_children(): - next_dict = {} if m in handler_collection and not isinstance( m, (nn.Sequential, nn.ModuleList) diff --git a/run_hyper.py b/run_hyper.py index 8fe9e1290..b66858268 100644 --- a/run_hyper.py +++ b/run_hyper.py @@ -21,7 +21,6 @@ def hyperopt_tune(args): - # plz set algo='exhaustive' to use exhaustive search, in this case, max_evals is auto set # in other case, max_evals needs to be set manually config_file_list = ( @@ -44,7 +43,6 @@ def hyperopt_tune(args): def ray_tune(args): - config_file_list = ( args.config_files.strip().split(" ") if args.config_files else None ) @@ -108,7 +106,6 @@ def ray_tune(args): if __name__ == "__main__": - parser = argparse.ArgumentParser() parser.add_argument( "--config_files", type=str, default=None, help="fixed config files" diff --git a/tests/config/test_command_line.py b/tests/config/test_command_line.py index cfd9ddce7..2c73a8e2a 100644 --- a/tests/config/test_command_line.py +++ b/tests/config/test_command_line.py @@ -12,7 +12,6 @@ if __name__ == "__main__": - config = Config(model="BPR", dataset="ml-100k") # command line diff --git a/tests/data/test_transform.py b/tests/data/test_transform.py index fc148de8f..ad430e73a 100644 --- a/tests/data/test_transform.py +++ b/tests/data/test_transform.py @@ -40,7 +40,6 @@ def new_transform(config_dict=None, config_file_list=None): class TestTransform: def test_mask_itemseq(self): - # TODO: add new test version checkpoint return diff --git a/tests/model/test_model_manual.py b/tests/model/test_model_manual.py index e1606e2a2..4ed8f9c46 100644 --- a/tests/model/test_model_manual.py +++ b/tests/model/test_model_manual.py @@ -20,7 +20,6 @@ def quick_test(config_dict): class TestSequentialRecommender(unittest.TestCase): - # def test_gru4reckg(self): # config_dict = { # 'model': 'GRU4RecKG',