Skip to content

negative_samples 实际运行有问题 #8

Description

@chenzelong

你好博主,感谢你的分享,我在运行过程中发现单独运行ESimCSE_train.py和单独运行ESimCSE_dataloader.py过程中negative_samples实际表现不一致,代码编辑如下:
def negative_samples(self, batch_src_text):
batch_size = len(batch_src_text)
print('*' * 10)
print('len(self.q):', len(self.q))
print('batch_size:', batch_size)
negative_samples = None
if len(self.q) > 0:
negative_samples = self.q[:self.q_size]
# print("size of negative_samples", len(negative_samples))
if len(self.q) + batch_size >= self.q_size:
del self.q[:batch_size]
self.q.extend(batch_src_text)
print('len(self.q)2:', len(self.q))
if negative_samples:
print('len(negative_samples):', len(negative_samples))
return negative_samples

ESimCSE_train.py打印日志如下:


len(self.q): 0
batch_size: 16
len(self.q)2: 16
##########


len(self.q): 0
batch_size: 16
len(self.q)2: 16
##########



len(self.q): 0
batch_size: 16
len(self.q): 0
len(self.q)2: 16
batch_size: 16
##########
len(self.q)2: 16
##########


len(self.q): 0
batch_size: 16
len(self.q)2: 16
##########

可以发现self.q赋值有问题,一直没找到问题根源在哪,希望可以一起讨论一下

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions