Skip to content

Support for conditional sampling #343

@isurulucky

Description

@isurulucky

Hi,

I tried out $subject and the implementation can be found in the PR #344.

I saw that there is already an issue created to change sampling implementation to top down, just sending this PR in case there is interest in using it till top down sampling is available. Would be happy to receive any suggestions for improvements. Planning to send a separate PR with some units tests, in case this is merged.

Code snippet for trying out conditional sampling:

    height = 28
    width = 28
    image_scope = np.array(range(height * width)).reshape(height, width)
    marginalize_idx = list(image_scope[0:round(height / 2), :].reshape(-1))
    vars_to_marginalize = Scope(marginalize_idx)
    sampling_query = SamplingQuery(cct)

    samples = sampling_query(x=input_to_condition.unsqueeze(1), integrate_vars=vars_to_marginalize)
    leaf_samples = samples[0]
    leaf_samples = leaf_samples[:, 0, :]

Thanks and regards,
Isuru

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions