april-tools / cirkit

a python framework to build, learn and reason about probabilistic circuits and tensor networks
https://cirkit-docs.readthedocs.io/en/latest/
GNU General Public License v3.0
80 stars 4 forks source link

Marginalization/integration implemented in PyTorch #270

Closed loreloc closed 2 months ago

loreloc commented 2 months ago

Example of usage:

from cirkit.backend.torch.queries import IntegrateQuery

# A compiled probabilistic circuit computing p(X)
circuit = ...

# Build the marginal query handler by specifying the circuit
marginal_query = IntegrateQuery(circuit)

# Evaluate a batch and marginalize different subsets of variables
marginal235_prob = marginal_query(batch, integrate_vars=Scope([2, 3, 5]))
marginal123_prob = marginal_query(batch, integrate_vars=Scope([1, 2, 3]))
codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 85.52632% with 22 lines in your changes missing coverage. Please review.

Project coverage is 71.03%. Comparing base (06abfe9) to head (f0a7933). Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
cirkit/backend/torch/layers/input.py 64.28% 11 Missing and 4 partials :warning:
cirkit/backend/torch/queries.py 82.85% 3 Missing and 3 partials :warning:
cirkit/backend/torch/graph/modules.py 94.44% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #270 +/- ## ========================================== + Coverage 70.85% 71.03% +0.18% ========================================== Files 44 45 +1 Lines 4464 4561 +97 Branches 651 659 +8 ========================================== + Hits 3163 3240 +77 - Misses 1130 1145 +15 - Partials 171 176 +5 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.