Update utils.py

now we can control the proportion
This commit is contained in:
XXXXRT666 2024-05-02 02:04:19 +01:00 committed by GitHub
parent db120aebc9
commit c52e080403
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -208,17 +208,17 @@ def make_reject_y(y_o, y_lens):
bs = len(y_lens)
reject_y = []
reject_y_lens = []
process_item_idx = True
proportion=0.5 # repeat/total
for b in range(bs):
if process_item_idx == True:
process_item_idx = torch.rand(1)
if process_item_idx < proportion:
new_y = repeat_P(y_o[b])
reject_y.append(new_y)
reject_y_lens.append(len(new_y))
elif process_item_idx == False:
else:
new_y = lost_P(y_o[b])
reject_y.append(new_y)
reject_y_lens.append(len(new_y))
process_item_idx = not process_item_idx
max_length = max(reject_y_lens)
for b in range(bs):
pad_length = max_length - reject_y_lens[b]