Skip to content

Conditional Sampling using Pytorch Samplers#38

Draft
alexander-koch wants to merge 5 commits intodevfrom
conditional_samplers
Draft

Conditional Sampling using Pytorch Samplers#38
alexander-koch wants to merge 5 commits intodevfrom
conditional_samplers

Conversation

@alexander-koch
Copy link
Collaborator

Implements conditional sampling using Pytorch samplers. Instead of implementing the functionality on a Pytorch dataset level, a scheduled sampler is created at the setup. This allows to implement conditional sampling with minimal changes to the codebase and requires no hard-coding. The dataframes can be used directly for conditioning information
and MultiModalDatsets do not need to ship with extra labels which would not be used by the end user.
Conditionings are created by the user of the following format:

class Conditioning:
    def __call__(self, label_row, df, generator):
        labels = df["target"]
        label = label_row["target"]

        dist = np.abs(labels - label)
        dist = np.argmin(dist)
        return dist

and can then be provided via jsonargparse in the yaml file directly as a classpath:

conditioning:
      class_path: example.condition.Conditioning

Conditioning classes should implement a call function that returns the index that should be sampled of the dataframe.
Ideally, the generator should be used to make this a somewhat non-deterministic process, unless the user wants a deterministic conditioning.

One restriction of this implementation is that max_steps needs to be set, because the random conditional schedule cannot be created on the fly.

Under the hood, permutations are created for the main dataset, simulating a virtual "walkthrough" until the dataloader is finished and has to restart with a new permutation. According to this schedule, the auxiliary and augmented dataset are then created using the user-provided conditioning.

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

Successfully merging this pull request may close these issues.

1 participant

Comments