From ac3d2b859c5d2224b1795ed6669804f6361ab086 Mon Sep 17 00:00:00 2001 From: Qdriving <35327911+Qdriving@users.noreply.github.com> Date: Mon, 28 Sep 2020 11:30:03 +0800 Subject: [PATCH] Update reader.py yapf check --- models/rank/dien/reader.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/models/rank/dien/reader.py b/models/rank/dien/reader.py index 2368a2d8..16ff27a6 100755 --- a/models/rank/dien/reader.py +++ b/models/rank/dien/reader.py @@ -95,15 +95,19 @@ class Reader(ReaderBase): self.neg_candidate_item.extend(b[i][0]) self.neg_candidate_cat.extend(b[i][1]) if len(self.neg_candidate_item) > self.max_neg_item: - self.neg_candidate_item = self.neg_candidate_item[0:self.max_neg_item] - self.neg_candidate_cat = self.neg_candidate_cat[0:self.max_neg_item] + self.neg_candidate_item = self.neg_candidate_item[ + 0:self.max_neg_item] + self.neg_candidate_cat = self.neg_candidate_cat[ + 0:self.max_neg_item] else: len_seq = len(b[i][0]) start_idx = random.randint(0, self.max_neg_item - len_seq - 1) - self.neg_candidate_item[start_idx:start_idx + len_seq + 1] = b[i][0] - self.neg_candidate_cat[start_idx:start_idx + len_seq + 1] = b[i][1] + self.neg_candidate_item[start_idx:start_idx + len_seq + + 1] = b[i][0] + self.neg_candidate_cat[start_idx:start_idx + len_seq + + 1] = b[i][1] - for _ in range(len(b[i][0])): + for _ in range(len(b[i][0])): randindex = random.randint(0, len(self.neg_candidate_item) - 1) neg_item[i].append(self.neg_candidate_item[randindex]) neg_cat[i].append(self.neg_candidate_cat[randindex]) -- GitLab