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

get_task_batch function from Generator #19

Open
ranyaphat29 opened this issue Oct 13, 2020 · 0 comments
Open

get_task_batch function from Generator #19

ranyaphat29 opened this issue Oct 13, 2020 · 0 comments

Comments

@ranyaphat29
Copy link

for batch_counter in range(batch_size):
positive_class = random.randint(0, n_way - 1)

        # Sample random classes for this TASK
        classes_ = list(self.data.keys())
        sampled_classes = random.sample(classes_, n_way)
        indexes_perm = np.random.permutation(n_way * num_shots)

        counter = 0
        for class_counter, class_ in enumerate(sampled_classes):
            if class_counter == positive_class:
                # We take num_shots + one sample for one class
                samples = random.sample(self.data[class_], num_shots+1)
                # Test sample is loaded
                batch_x[batch_counter, :, :, :] = samples[0]
                labels_x[batch_counter, class_counter] = 1
                labels_x_global[batch_counter] = self.class_encoder[class_]
                samples = samples[1::]
            else:
                samples = random.sample(self.data[class_], num_shots)

Why we need positive class ? What is the meaning of indexes perm ?and why we set labels_x[batch_counter, class_counter] = 1 by class_counter instead of using class_?

Thanks,

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