Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataloader.py get_captions() random sample times #261

Open
Eajay opened this issue Oct 22, 2021 · 0 comments
Open

dataloader.py get_captions() random sample times #261

Eajay opened this issue Oct 22, 2021 · 0 comments

Comments

@Eajay
Copy link

Eajay commented Oct 22, 2021

original:

        if ncap < seq_per_img:
            # we need to subsample (with replacement)
            seq = np.zeros([seq_per_img, self.seq_length], dtype = 'int')
            for q in range(seq_per_img):
                ixl = random.randint(ix1,ix2)
                seq[q, :] = self.label[ixl, :self.seq_length]

Suppose seq_per_img=5, ncap=3
This will random select caption 5 times, some captions might not be selected

How about changing to:

       if ncap < seq_per_img:
            # we need to subsample (with replacement)
            seq = np.zeros([seq_per_img, self.seq_length], dtype='int')
            seq[: ncap, :] = self.label[ix1: ix1+ncap, :self.seq_length]
            for q in range(ncap, seq_per_img):
                ixl = random.randint(ix1, ix2)
                seq[q, :] = self.label[ixl, :self.seq_length]

So we can keep 3 captions and only randomly sample 2 times

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant