pyjuice

PC Creation

inputs

Construct a vector of input nodes defined on the same variable and have the same input distribution.

multiply

Construct a vector of product nodes given a list of children PCs defined on disjoint sets of variables.

summate

Construct a vector of sum nodes given a list of children PCs defined on the same sets of variables.

set_block_size

Context-manager that sets the block size of PC nodes constructed by inputs, multiply, and summate.

structural_properties

Context-manager that controls the assertions of circuit structural properties, including smoothness and decomposability.

PC Structure Transformation

merge

Merge nodes with identical region node together.

blockify

Generate an equivalent PC with potentially high block sizes.

unblockify

Decrease the block size of a PC.

deepcopy

Create a deepcopy of the input PC.

grow

Grow a PC by creating duplicates of all nodes (except for the root node).

prune_by_score

Prune sum-edge connections from a PC based on per-edge scores, returning a new, sparser PC.

bump_block_size

Return a copy of a node group whose block size is increased to block_size (which must be a multiple of the current block size and divide the number of nodes), re-packing its parameters and edges accordingly.

PC Compilation

compile

Compile a PC represented by a DAG into an equivalent torch.nn.Module.

IO

load

Load a PC from file.

save

Save a PC to file.