diff --git a/.buildinfo b/.buildinfo index 9acddaf2..786dad08 100644 --- a/.buildinfo +++ b/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 39366f9605333641156b8d78b6580d6b +config: 45f46a47a2b1a98e61f5e88465e68f9a tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/.doctrees/environment.pickle b/.doctrees/environment.pickle index 40b88e2b..7e61b4ea 100644 Binary files a/.doctrees/environment.pickle and b/.doctrees/environment.pickle differ diff --git a/.doctrees/getting-started/tutorials/02_construct_simple_pc.doctree b/.doctrees/getting-started/tutorials/02_construct_simple_pc.doctree index c52c6177..67f91b6a 100644 Binary files a/.doctrees/getting-started/tutorials/02_construct_simple_pc.doctree and b/.doctrees/getting-started/tutorials/02_construct_simple_pc.doctree differ diff --git a/.doctrees/getting-started/tutorials/03_construct_hmm.doctree b/.doctrees/getting-started/tutorials/03_construct_hmm.doctree index e81b5c48..eddef6dc 100644 Binary files a/.doctrees/getting-started/tutorials/03_construct_hmm.doctree and b/.doctrees/getting-started/tutorials/03_construct_hmm.doctree differ diff --git a/.doctrees/getting-started/tutorials/05_common_transformations.doctree b/.doctrees/getting-started/tutorials/05_common_transformations.doctree index 398f7770..66e24ad5 100644 Binary files a/.doctrees/getting-started/tutorials/05_common_transformations.doctree and b/.doctrees/getting-started/tutorials/05_common_transformations.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.blockify.doctree b/.doctrees/python-api/generated/pyjuice.blockify.doctree index 39b3f34f..6a6f000c 100644 Binary files a/.doctrees/python-api/generated/pyjuice.blockify.doctree and b/.doctrees/python-api/generated/pyjuice.blockify.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.compile.doctree b/.doctrees/python-api/generated/pyjuice.compile.doctree index 53549b79..76390e12 100644 Binary files a/.doctrees/python-api/generated/pyjuice.compile.doctree and b/.doctrees/python-api/generated/pyjuice.compile.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.deepcopy.doctree b/.doctrees/python-api/generated/pyjuice.deepcopy.doctree index 5412ed7b..a248baba 100644 Binary files a/.doctrees/python-api/generated/pyjuice.deepcopy.doctree and b/.doctrees/python-api/generated/pyjuice.deepcopy.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.inputs.doctree b/.doctrees/python-api/generated/pyjuice.inputs.doctree index 50a309fa..3fa553a4 100644 Binary files a/.doctrees/python-api/generated/pyjuice.inputs.doctree and b/.doctrees/python-api/generated/pyjuice.inputs.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.load.doctree b/.doctrees/python-api/generated/pyjuice.load.doctree index 24f3e409..22bb939c 100644 Binary files a/.doctrees/python-api/generated/pyjuice.load.doctree and b/.doctrees/python-api/generated/pyjuice.load.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.merge.doctree b/.doctrees/python-api/generated/pyjuice.merge.doctree index c8b0786f..c2dd14e7 100644 Binary files a/.doctrees/python-api/generated/pyjuice.merge.doctree and b/.doctrees/python-api/generated/pyjuice.merge.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.multiply.doctree b/.doctrees/python-api/generated/pyjuice.multiply.doctree index 856504c2..23348693 100644 Binary files a/.doctrees/python-api/generated/pyjuice.multiply.doctree and b/.doctrees/python-api/generated/pyjuice.multiply.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.nodes.InputNodes.doctree b/.doctrees/python-api/generated/pyjuice.nodes.InputNodes.doctree index 2265ec66..b36684db 100644 Binary files a/.doctrees/python-api/generated/pyjuice.nodes.InputNodes.doctree and b/.doctrees/python-api/generated/pyjuice.nodes.InputNodes.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.nodes.ProdNodes.doctree b/.doctrees/python-api/generated/pyjuice.nodes.ProdNodes.doctree index 9b5fb6de..bba2b2b4 100644 Binary files a/.doctrees/python-api/generated/pyjuice.nodes.ProdNodes.doctree and b/.doctrees/python-api/generated/pyjuice.nodes.ProdNodes.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.nodes.SumNodes.doctree b/.doctrees/python-api/generated/pyjuice.nodes.SumNodes.doctree index 3919e323..c323a2ff 100644 Binary files a/.doctrees/python-api/generated/pyjuice.nodes.SumNodes.doctree and b/.doctrees/python-api/generated/pyjuice.nodes.SumNodes.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.nodes.distributions.Bernoulli.doctree b/.doctrees/python-api/generated/pyjuice.nodes.distributions.Bernoulli.doctree index 8b663488..8407706e 100644 Binary files a/.doctrees/python-api/generated/pyjuice.nodes.distributions.Bernoulli.doctree and b/.doctrees/python-api/generated/pyjuice.nodes.distributions.Bernoulli.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.nodes.distributions.Categorical.doctree b/.doctrees/python-api/generated/pyjuice.nodes.distributions.Categorical.doctree index 05bb4ab8..34fde567 100644 Binary files a/.doctrees/python-api/generated/pyjuice.nodes.distributions.Categorical.doctree and b/.doctrees/python-api/generated/pyjuice.nodes.distributions.Categorical.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.nodes.distributions.DiscreteLogistic.doctree b/.doctrees/python-api/generated/pyjuice.nodes.distributions.DiscreteLogistic.doctree index 04ace90f..7031dbba 100644 Binary files a/.doctrees/python-api/generated/pyjuice.nodes.distributions.DiscreteLogistic.doctree and b/.doctrees/python-api/generated/pyjuice.nodes.distributions.DiscreteLogistic.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.nodes.distributions.Gaussian.doctree b/.doctrees/python-api/generated/pyjuice.nodes.distributions.Gaussian.doctree index bfe7144e..f980c091 100644 Binary files a/.doctrees/python-api/generated/pyjuice.nodes.distributions.Gaussian.doctree and b/.doctrees/python-api/generated/pyjuice.nodes.distributions.Gaussian.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.nodes.distributions.MaskedCategorical.doctree b/.doctrees/python-api/generated/pyjuice.nodes.distributions.MaskedCategorical.doctree index 3c04c8d6..fcf2a225 100644 Binary files a/.doctrees/python-api/generated/pyjuice.nodes.distributions.MaskedCategorical.doctree and b/.doctrees/python-api/generated/pyjuice.nodes.distributions.MaskedCategorical.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.nodes.foldup_aggregate.doctree b/.doctrees/python-api/generated/pyjuice.nodes.foldup_aggregate.doctree index 7f4d4d87..80917bfc 100644 Binary files a/.doctrees/python-api/generated/pyjuice.nodes.foldup_aggregate.doctree and b/.doctrees/python-api/generated/pyjuice.nodes.foldup_aggregate.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.nodes.foreach.doctree b/.doctrees/python-api/generated/pyjuice.nodes.foreach.doctree index 728b67fb..17c865a2 100644 Binary files a/.doctrees/python-api/generated/pyjuice.nodes.foreach.doctree and b/.doctrees/python-api/generated/pyjuice.nodes.foreach.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.save.doctree b/.doctrees/python-api/generated/pyjuice.save.doctree index 5e441b3e..b943227b 100644 Binary files a/.doctrees/python-api/generated/pyjuice.save.doctree and b/.doctrees/python-api/generated/pyjuice.save.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.set_block_size.doctree b/.doctrees/python-api/generated/pyjuice.set_block_size.doctree index c5991522..458a3855 100644 Binary files a/.doctrees/python-api/generated/pyjuice.set_block_size.doctree and b/.doctrees/python-api/generated/pyjuice.set_block_size.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.structures.HCLT.doctree b/.doctrees/python-api/generated/pyjuice.structures.HCLT.doctree index fcf6d745..b00c2f1c 100644 Binary files a/.doctrees/python-api/generated/pyjuice.structures.HCLT.doctree and b/.doctrees/python-api/generated/pyjuice.structures.HCLT.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.structures.HMM.doctree b/.doctrees/python-api/generated/pyjuice.structures.HMM.doctree index c3b8885c..2406a4f2 100644 Binary files a/.doctrees/python-api/generated/pyjuice.structures.HMM.doctree and b/.doctrees/python-api/generated/pyjuice.structures.HMM.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.structures.PD.doctree b/.doctrees/python-api/generated/pyjuice.structures.PD.doctree index 3228f398..969fb1b2 100644 Binary files a/.doctrees/python-api/generated/pyjuice.structures.PD.doctree and b/.doctrees/python-api/generated/pyjuice.structures.PD.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.structures.RAT_SPN.doctree b/.doctrees/python-api/generated/pyjuice.structures.RAT_SPN.doctree index 232b5213..b6fed160 100644 Binary files a/.doctrees/python-api/generated/pyjuice.structures.RAT_SPN.doctree and b/.doctrees/python-api/generated/pyjuice.structures.RAT_SPN.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.summate.doctree b/.doctrees/python-api/generated/pyjuice.summate.doctree index 6be62940..72f6bb3f 100644 Binary files a/.doctrees/python-api/generated/pyjuice.summate.doctree and b/.doctrees/python-api/generated/pyjuice.summate.doctree differ diff --git a/.doctrees/python-api/generated/pyjuice.unblockify.doctree b/.doctrees/python-api/generated/pyjuice.unblockify.doctree index 96b61c48..d1161e01 100644 Binary files a/.doctrees/python-api/generated/pyjuice.unblockify.doctree and b/.doctrees/python-api/generated/pyjuice.unblockify.doctree differ diff --git a/.doctrees/python-api/nodes.doctree b/.doctrees/python-api/nodes.doctree index e51cfaef..8bed676c 100644 Binary files a/.doctrees/python-api/nodes.doctree and b/.doctrees/python-api/nodes.doctree differ diff --git a/.doctrees/python-api/pyjuice.doctree b/.doctrees/python-api/pyjuice.doctree index c63301eb..1deea431 100644 Binary files a/.doctrees/python-api/pyjuice.doctree and b/.doctrees/python-api/pyjuice.doctree differ diff --git a/.doctrees/python-api/structures.doctree b/.doctrees/python-api/structures.doctree index 12c1185c..0be12134 100644 Binary files a/.doctrees/python-api/structures.doctree and b/.doctrees/python-api/structures.doctree differ diff --git a/.doctrees/python-api/tensorcircuit.doctree b/.doctrees/python-api/tensorcircuit.doctree index 707317c9..a3ee333c 100644 Binary files a/.doctrees/python-api/tensorcircuit.doctree and b/.doctrees/python-api/tensorcircuit.doctree differ diff --git a/_downloads/3988e2237cc0401749dcb522c104a647/05_common_transformations.ipynb b/_downloads/3988e2237cc0401749dcb522c104a647/05_common_transformations.ipynb index 7aa2d3e3..d51ff71e 100644 --- a/_downloads/3988e2237cc0401749dcb522c104a647/05_common_transformations.ipynb +++ b/_downloads/3988e2237cc0401749dcb522c104a647/05_common_transformations.ipynb @@ -15,7 +15,25 @@ }, "outputs": [], "source": [ - "# sphinx_gallery_thumbnail_path = 'imgs/juice.png'\n\nimport torch\nimport pyjuice as juice\nimport pyjuice.nodes.distributions as dists" + "# sphinx_gallery_thumbnail_path = 'imgs/juice.png'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's start by importing the necessary packages.\n\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import torch\nimport pyjuice as juice\nimport pyjuice.nodes.distributions as dists" ] }, { diff --git a/_downloads/4407a3dbbb1547f15d94cab7374d606b/03_construct_hmm.py b/_downloads/4407a3dbbb1547f15d94cab7374d606b/03_construct_hmm.py index bb95e2d1..e482662c 100644 --- a/_downloads/4407a3dbbb1547f15d94cab7374d606b/03_construct_hmm.py +++ b/_downloads/4407a3dbbb1547f15d94cab7374d606b/03_construct_hmm.py @@ -7,6 +7,9 @@ # sphinx_gallery_thumbnail_path = 'imgs/juice.png' +# %% +# Let's start by importing the necessary packages. + import torch import pyjuice as juice import pyjuice.nodes.distributions as dists diff --git a/_downloads/5871728fbee9fa77cb6f3d50f136f2e8/05_common_transformations.py b/_downloads/5871728fbee9fa77cb6f3d50f136f2e8/05_common_transformations.py index 5486f3f3..3a87597a 100644 --- a/_downloads/5871728fbee9fa77cb6f3d50f136f2e8/05_common_transformations.py +++ b/_downloads/5871728fbee9fa77cb6f3d50f136f2e8/05_common_transformations.py @@ -7,6 +7,9 @@ # sphinx_gallery_thumbnail_path = 'imgs/juice.png' +# %% +# Let's start by importing the necessary packages. + import torch import pyjuice as juice import pyjuice.nodes.distributions as dists diff --git a/_downloads/662999063954282841dc90b8945f85ce/tutorials_jupyter.zip b/_downloads/662999063954282841dc90b8945f85ce/tutorials_jupyter.zip index d339f1f8..418cc304 100644 Binary files a/_downloads/662999063954282841dc90b8945f85ce/tutorials_jupyter.zip and b/_downloads/662999063954282841dc90b8945f85ce/tutorials_jupyter.zip differ diff --git a/_downloads/763344228ae6bc253ed1a6cf586aa30d/tutorials_python.zip b/_downloads/763344228ae6bc253ed1a6cf586aa30d/tutorials_python.zip index 62201661..d9cf232a 100644 Binary files a/_downloads/763344228ae6bc253ed1a6cf586aa30d/tutorials_python.zip and b/_downloads/763344228ae6bc253ed1a6cf586aa30d/tutorials_python.zip differ diff --git a/_downloads/94056bd45c0afc58d516144c0928bf8b/02_construct_simple_pc.ipynb b/_downloads/94056bd45c0afc58d516144c0928bf8b/02_construct_simple_pc.ipynb index 01edde8a..c8a40d2d 100644 --- a/_downloads/94056bd45c0afc58d516144c0928bf8b/02_construct_simple_pc.ipynb +++ b/_downloads/94056bd45c0afc58d516144c0928bf8b/02_construct_simple_pc.ipynb @@ -15,7 +15,25 @@ }, "outputs": [], "source": [ - "# sphinx_gallery_thumbnail_path = 'imgs/juice.png'\n\nimport torch\nimport pyjuice as juice\nimport pyjuice.nodes.distributions as dists" + "# sphinx_gallery_thumbnail_path = 'imgs/juice.png'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's start by importing the necessary packages.\n\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import torch\nimport pyjuice as juice\nimport pyjuice.nodes.distributions as dists" ] }, { diff --git a/_downloads/a6f4e70e566387d03c9a1773c5f52cdb/03_construct_hmm.ipynb b/_downloads/a6f4e70e566387d03c9a1773c5f52cdb/03_construct_hmm.ipynb index ca7da34f..7dca4dc6 100644 --- a/_downloads/a6f4e70e566387d03c9a1773c5f52cdb/03_construct_hmm.ipynb +++ b/_downloads/a6f4e70e566387d03c9a1773c5f52cdb/03_construct_hmm.ipynb @@ -15,7 +15,25 @@ }, "outputs": [], "source": [ - "# sphinx_gallery_thumbnail_path = 'imgs/juice.png'\n\nimport torch\nimport pyjuice as juice\nimport pyjuice.nodes.distributions as dists" + "# sphinx_gallery_thumbnail_path = 'imgs/juice.png'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's start by importing the necessary packages.\n\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import torch\nimport pyjuice as juice\nimport pyjuice.nodes.distributions as dists" ] }, { diff --git a/_downloads/ab853d12dcf8246e42ce1eb5d40a84fb/02_construct_simple_pc.py b/_downloads/ab853d12dcf8246e42ce1eb5d40a84fb/02_construct_simple_pc.py index a870af75..20c1c75f 100644 --- a/_downloads/ab853d12dcf8246e42ce1eb5d40a84fb/02_construct_simple_pc.py +++ b/_downloads/ab853d12dcf8246e42ce1eb5d40a84fb/02_construct_simple_pc.py @@ -7,6 +7,9 @@ # sphinx_gallery_thumbnail_path = 'imgs/juice.png' +# %% +# Let's start by importing the necessary packages. + import torch import pyjuice as juice import pyjuice.nodes.distributions as dists diff --git a/_sources/getting-started/tutorials/02_construct_simple_pc.rst.txt b/_sources/getting-started/tutorials/02_construct_simple_pc.rst.txt index 7609511f..c1d90be5 100644 --- a/_sources/getting-started/tutorials/02_construct_simple_pc.rst.txt +++ b/_sources/getting-started/tutorials/02_construct_simple_pc.rst.txt @@ -23,33 +23,43 @@ Construct Simple PCs In this tutorial, you will learn about the basic APIs to construct PCs. -.. GENERATED FROM PYTHON SOURCE LINES 7-14 +.. GENERATED FROM PYTHON SOURCE LINES 7-10 .. code-block:: Python # sphinx_gallery_thumbnail_path = 'imgs/juice.png' + +.. GENERATED FROM PYTHON SOURCE LINES 11-12 + +Let's start by importing the necessary packages. + +.. GENERATED FROM PYTHON SOURCE LINES 12-17 + +.. code-block:: Python + + import torch import pyjuice as juice import pyjuice.nodes.distributions as dists -.. GENERATED FROM PYTHON SOURCE LINES 15-17 +.. GENERATED FROM PYTHON SOURCE LINES 18-20 A PC can be created using :code:`pyjuice.inputs`, :code:`pyjuice.multiply`, and :code:`pyjuice.summate`, which create input node vectors, product node vectors, and sum node vectors, respectively. The goal of this tutorial is to get you familiar with these functions. -.. GENERATED FROM PYTHON SOURCE LINES 19-21 +.. GENERATED FROM PYTHON SOURCE LINES 22-24 Input nodes ----------- -.. GENERATED FROM PYTHON SOURCE LINES 23-24 +.. GENERATED FROM PYTHON SOURCE LINES 26-27 Let us start with :code:`pyjuice.inputs`. -.. GENERATED FROM PYTHON SOURCE LINES 24-27 +.. GENERATED FROM PYTHON SOURCE LINES 27-30 .. code-block:: Python @@ -57,7 +67,7 @@ Let us start with :code:`pyjuice.inputs`. ni0 = juice.inputs(var = 0, num_node_blocks = 4, block_size = 2, dist = dists.Categorical(num_cats = 4)) -.. GENERATED FROM PYTHON SOURCE LINES 28-35 +.. GENERATED FROM PYTHON SOURCE LINES 31-38 The above line defines :code:`num_node_blocks * block_size = 8` input nodes on variable ID :code:`var = 0` featuring Categorical distributions with 4 categories (i.e., :code:`dists.Categorical(num_cats = 4)`). The set of input distributions are defined under :code:`pyjuice.nodes.distributions`. @@ -67,16 +77,16 @@ Although using larger block sizes when defining input node vectors do not have a Note that :code:`block_size` has to be a power of 2. -.. GENERATED FROM PYTHON SOURCE LINES 37-39 +.. GENERATED FROM PYTHON SOURCE LINES 40-42 Product nodes ------------- -.. GENERATED FROM PYTHON SOURCE LINES 41-42 +.. GENERATED FROM PYTHON SOURCE LINES 44-45 Let us define another input node vector and a product node vector that take the input nodes as children. -.. GENERATED FROM PYTHON SOURCE LINES 42-48 +.. GENERATED FROM PYTHON SOURCE LINES 45-51 .. code-block:: Python @@ -87,7 +97,7 @@ Let us define another input node vector and a product node vector that take the ms = juice.multiply(ni0, ni1, edge_ids = edge_ids) -.. GENERATED FROM PYTHON SOURCE LINES 49-59 +.. GENERATED FROM PYTHON SOURCE LINES 52-62 :code:`ms` defines a product node vector where every node have two children: the first child is a node in :code:`ni0` and the second child is a node in :code:`ni1`. :code:`edge_ids` specifies which child nodes do every node in :code:`ms` connects to. Specifically, :code:`edge_ids` has size :code:`[# product node blocks, # child node vectors]`, so in this case, it should has size :code:`[4, 2]`. @@ -100,7 +110,7 @@ For :code:`pyjuice.multiply`, if two node blocks are connected (as defined by :c When we do not provide the :code:`edge_ids`, PyJuice assumes it to be the following (we can only use this shortcut when the child node vectors have the same :code:`num_node_blocks` and :code:`block_size`): -.. GENERATED FROM PYTHON SOURCE LINES 59-64 +.. GENERATED FROM PYTHON SOURCE LINES 62-67 .. code-block:: Python @@ -110,16 +120,16 @@ When we do not provide the :code:`edge_ids`, PyJuice assumes it to be the follow edge_ids = torch.arange(0, num_node_blocks)[:,None].repeat(1, num_child_node_vectors) -.. GENERATED FROM PYTHON SOURCE LINES 65-67 +.. GENERATED FROM PYTHON SOURCE LINES 68-70 Sum nodes --------- -.. GENERATED FROM PYTHON SOURCE LINES 69-70 +.. GENERATED FROM PYTHON SOURCE LINES 72-73 Finally, we introduce :code:`pyjuice.summate`, which is used to define sum node vectors. -.. GENERATED FROM PYTHON SOURCE LINES 70-74 +.. GENERATED FROM PYTHON SOURCE LINES 73-77 .. code-block:: Python @@ -128,7 +138,7 @@ Finally, we introduce :code:`pyjuice.summate`, which is used to define sum node ns = juice.summate(ms, num_node_blocks = 6, block_size = 2, edge_ids = edge_ids) -.. GENERATED FROM PYTHON SOURCE LINES 75-85 +.. GENERATED FROM PYTHON SOURCE LINES 78-88 Similar to :code:`pyjuice.multiply`, the positional arguments to :code:`pyjuice.summate` are the list of input node vectors (here we only provide :code:`ms`). :code:`num_node_blocks` and :code:`block_size` are the number of node blocks and the size of each node block, respectively. @@ -141,7 +151,7 @@ That is, in the case where both :code:`ns` and :code:`ms` have block size 2, eve If :code:`edge_ids` is not provided, we assume that all nodes in the sum node vector are connected to all child nodes: -.. GENERATED FROM PYTHON SOURCE LINES 85-86 +.. GENERATED FROM PYTHON SOURCE LINES 88-89 .. code-block:: Python diff --git a/_sources/getting-started/tutorials/03_construct_hmm.rst.txt b/_sources/getting-started/tutorials/03_construct_hmm.rst.txt index f60efb92..adf1d3eb 100644 --- a/_sources/getting-started/tutorials/03_construct_hmm.rst.txt +++ b/_sources/getting-started/tutorials/03_construct_hmm.rst.txt @@ -23,23 +23,33 @@ Construct an HMM This tutorial demonstrates how to construct an HMM with :code:`pyjuice.inputs`, :code:`pyjuice.multiply`, and :code:`pyjuice.summate`. -.. GENERATED FROM PYTHON SOURCE LINES 7-14 +.. GENERATED FROM PYTHON SOURCE LINES 7-10 .. code-block:: Python # sphinx_gallery_thumbnail_path = 'imgs/juice.png' + +.. GENERATED FROM PYTHON SOURCE LINES 11-12 + +Let's start by importing the necessary packages. + +.. GENERATED FROM PYTHON SOURCE LINES 12-17 + +.. code-block:: Python + + import torch import pyjuice as juice import pyjuice.nodes.distributions as dists -.. GENERATED FROM PYTHON SOURCE LINES 15-16 +.. GENERATED FROM PYTHON SOURCE LINES 18-19 We start with specifying the structural parameters of the HMM -.. GENERATED FROM PYTHON SOURCE LINES 16-21 +.. GENERATED FROM PYTHON SOURCE LINES 19-24 .. code-block:: Python @@ -49,12 +59,12 @@ We start with specifying the structural parameters of the HMM num_emits = 4023 -.. GENERATED FROM PYTHON SOURCE LINES 22-24 +.. GENERATED FROM PYTHON SOURCE LINES 25-27 An important parameter to be determined is the block size, which is crucial for PyJuice to compile efficient models. Specifically, we want the block size to be large enough so that PyJuice can leverage block-based parallelization. -.. GENERATED FROM PYTHON SOURCE LINES 24-27 +.. GENERATED FROM PYTHON SOURCE LINES 27-30 .. code-block:: Python @@ -62,11 +72,11 @@ Specifically, we want the block size to be large enough so that PyJuice can leve block_size = min(juice.utils.util.max_cdf_power_of_2(num_latents), 1024) -.. GENERATED FROM PYTHON SOURCE LINES 28-29 +.. GENERATED FROM PYTHON SOURCE LINES 31-32 The number of node blocks is derived accordingly -.. GENERATED FROM PYTHON SOURCE LINES 29-32 +.. GENERATED FROM PYTHON SOURCE LINES 32-35 .. code-block:: Python @@ -74,12 +84,12 @@ The number of node blocks is derived accordingly num_node_blocks = num_latents // block_size -.. GENERATED FROM PYTHON SOURCE LINES 33-35 +.. GENERATED FROM PYTHON SOURCE LINES 36-38 We use the context manager `set_block_size` to set the block size of all PC nodes. In the following we assume `T = seq_length` and `K = num_latents` -.. GENERATED FROM PYTHON SOURCE LINES 35-61 +.. GENERATED FROM PYTHON SOURCE LINES 38-64 .. code-block:: Python @@ -110,7 +120,7 @@ In the following we assume `T = seq_length` and `K = num_latents` ns = juice.summate(curr_zs, num_node_blocks = 1, block_size = 1) -.. GENERATED FROM PYTHON SOURCE LINES 62-68 +.. GENERATED FROM PYTHON SOURCE LINES 65-71 Note that :code:`ns.duplication` is a handy function to create duplications of existing node vectors. For input nodes (e.g., :code:`ns_input.duplicate(var, tie_params = True)`) we can specify it to define on a new variable. diff --git a/_sources/getting-started/tutorials/05_common_transformations.rst.txt b/_sources/getting-started/tutorials/05_common_transformations.rst.txt index 6b12059c..66cd7c85 100644 --- a/_sources/getting-started/tutorials/05_common_transformations.rst.txt +++ b/_sources/getting-started/tutorials/05_common_transformations.rst.txt @@ -23,29 +23,39 @@ PC Structural Transformation Functions In this tutorial, you will learn how to use the built-in structural transformation algorithms to easily create and manipulate PCs. -.. GENERATED FROM PYTHON SOURCE LINES 7-14 +.. GENERATED FROM PYTHON SOURCE LINES 7-10 .. code-block:: Python # sphinx_gallery_thumbnail_path = 'imgs/juice.png' + +.. GENERATED FROM PYTHON SOURCE LINES 11-12 + +Let's start by importing the necessary packages. + +.. GENERATED FROM PYTHON SOURCE LINES 12-17 + +.. code-block:: Python + + import torch import pyjuice as juice import pyjuice.nodes.distributions as dists -.. GENERATED FROM PYTHON SOURCE LINES 15-17 +.. GENERATED FROM PYTHON SOURCE LINES 18-20 Clone a PC ---------- -.. GENERATED FROM PYTHON SOURCE LINES 19-21 +.. GENERATED FROM PYTHON SOURCE LINES 22-24 :code:`pyjuice.deepcopy` allows us to clone a PC, with some options to manipulate the copy. Let's start by defining a PC. -.. GENERATED FROM PYTHON SOURCE LINES 21-35 +.. GENERATED FROM PYTHON SOURCE LINES 24-38 .. code-block:: Python @@ -64,11 +74,11 @@ Let's start by defining a PC. ns.init_parameters() -.. GENERATED FROM PYTHON SOURCE LINES 36-37 +.. GENERATED FROM PYTHON SOURCE LINES 39-40 To create an independent copy of :code:`ns`, we can run: -.. GENERATED FROM PYTHON SOURCE LINES 37-40 +.. GENERATED FROM PYTHON SOURCE LINES 40-43 .. code-block:: Python @@ -76,11 +86,11 @@ To create an independent copy of :code:`ns`, we can run: new_ns1 = juice.deepcopy(ns) -.. GENERATED FROM PYTHON SOURCE LINES 41-42 +.. GENERATED FROM PYTHON SOURCE LINES 44-45 By setting :code:`tie_params` to :code:`True`, we can tie the parameters of the original PC with that of the copied PC. Note that tied parameters will remain the same during all transformation/learning procedures implemented in PyJuice. -.. GENERATED FROM PYTHON SOURCE LINES 42-45 +.. GENERATED FROM PYTHON SOURCE LINES 45-48 .. code-block:: Python @@ -88,11 +98,11 @@ By setting :code:`tie_params` to :code:`True`, we can tie the parameters of the new_ns2 = juice.deepcopy(ns, tie_params = True) -.. GENERATED FROM PYTHON SOURCE LINES 46-47 +.. GENERATED FROM PYTHON SOURCE LINES 49-50 By providing a :code:`var_mapping`, we can define the copied PC on another set of variables. -.. GENERATED FROM PYTHON SOURCE LINES 47-51 +.. GENERATED FROM PYTHON SOURCE LINES 50-54 .. code-block:: Python @@ -101,11 +111,11 @@ By providing a :code:`var_mapping`, we can define the copied PC on another set o new_ns3 = juice.deepcopy(ns, var_mapping = var_mapping) -.. GENERATED FROM PYTHON SOURCE LINES 52-53 +.. GENERATED FROM PYTHON SOURCE LINES 55-56 Note that :code:`tie_params` and :code:`var_mapping` can be used simultaneously: -.. GENERATED FROM PYTHON SOURCE LINES 53-56 +.. GENERATED FROM PYTHON SOURCE LINES 56-59 .. code-block:: Python @@ -113,17 +123,17 @@ Note that :code:`tie_params` and :code:`var_mapping` can be used simultaneously: new_ns3 = juice.deepcopy(ns, tie_params = True, var_mapping = var_mapping) -.. GENERATED FROM PYTHON SOURCE LINES 57-59 +.. GENERATED FROM PYTHON SOURCE LINES 60-62 Merge PCs --------- -.. GENERATED FROM PYTHON SOURCE LINES 61-63 +.. GENERATED FROM PYTHON SOURCE LINES 64-66 :code:`juice.merge` can be used to collapse vectors of nodes defined on the same variable scope into a single vector of nodes. Take the following PC as an example: -.. GENERATED FROM PYTHON SOURCE LINES 63-76 +.. GENERATED FROM PYTHON SOURCE LINES 66-79 .. code-block:: Python @@ -141,12 +151,12 @@ Take the following PC as an example: ns = juice.summate(ms00, ms01, num_node_blocks = 1, block_size = 1) -.. GENERATED FROM PYTHON SOURCE LINES 77-79 +.. GENERATED FROM PYTHON SOURCE LINES 80-82 In the above PC (i.e., :code:`ns`), :code:`i00` and :code:`i01` (also :code:`i10` and :code:`i11`) can be merged into a single object since they define on the same variable and has the same distribution. :code:`juice.merge` outputs an equivalent PC with the objects properly merged: -.. GENERATED FROM PYTHON SOURCE LINES 79-82 +.. GENERATED FROM PYTHON SOURCE LINES 82-85 .. code-block:: Python @@ -154,11 +164,11 @@ In the above PC (i.e., :code:`ns`), :code:`i00` and :code:`i01` (also :code:`i10 new_ns1 = juice.merge(ns) -.. GENERATED FROM PYTHON SOURCE LINES 83-84 +.. GENERATED FROM PYTHON SOURCE LINES 86-87 Another usage of the merge function is to "concatenate" nodes defined by multiple PyJuice objects, if they are defined on the same set of variables. -.. GENERATED FROM PYTHON SOURCE LINES 84-90 +.. GENERATED FROM PYTHON SOURCE LINES 87-93 .. code-block:: Python @@ -169,21 +179,21 @@ Another usage of the merge function is to "concatenate" nodes defined by multipl new_ns2 = juice.merge(ns0, ns1) -.. GENERATED FROM PYTHON SOURCE LINES 91-92 +.. GENERATED FROM PYTHON SOURCE LINES 94-95 :code:`new_ns2` will also be equivalent to :code:`ns`. -.. GENERATED FROM PYTHON SOURCE LINES 94-96 +.. GENERATED FROM PYTHON SOURCE LINES 97-99 Adjust block sizes ------------------ -.. GENERATED FROM PYTHON SOURCE LINES 98-100 +.. GENERATED FROM PYTHON SOURCE LINES 101-103 In the second tutorial (i.e., "Construct Simple PCs"), we mentioned that defining PCs with large :code:`block_size` is crucial to their efficiency. While the best practice is to set high block sizes manually whenever possible, we provide :code:`pyjuice.blockify` to try bumping the group size of all vectors of nodes within a PC. -.. GENERATED FROM PYTHON SOURCE LINES 100-119 +.. GENERATED FROM PYTHON SOURCE LINES 103-122 .. code-block:: Python @@ -207,12 +217,12 @@ While the best practice is to set high block sizes manually whenever possible, w ns.init_parameters() -.. GENERATED FROM PYTHON SOURCE LINES 120-122 +.. GENERATED FROM PYTHON SOURCE LINES 123-125 While the block sizes of the above-defined PC is 2 (except for the root node), :code:`ns1` could have block size 4 since every pair of 4 aligned sum nodes in :code:`ns1` and 4 aligned child nodes are fully connected. To apply such change, we can use: -.. GENERATED FROM PYTHON SOURCE LINES 122-125 +.. GENERATED FROM PYTHON SOURCE LINES 125-128 .. code-block:: Python @@ -220,7 +230,7 @@ To apply such change, we can use: new_ns = juice.blockify(ns, sparsity_tolerance = 0.25, max_target_block_size = 32) -.. GENERATED FROM PYTHON SOURCE LINES 126-127 +.. GENERATED FROM PYTHON SOURCE LINES 129-130 There are two parameters to the function. :code:`max_target_block_size` specifies the maximum block size to be considered; :code:`sparsity_tolerance` specifies what fraction of pseudo-edges do we allow to add in order to increase the block size even if some pairs of parent and child node blocks are neither fully-connected nor unconnected. diff --git a/_static/searchtools.js b/_static/searchtools.js index 92da3f8b..b08d58c9 100644 --- a/_static/searchtools.js +++ b/_static/searchtools.js @@ -178,7 +178,7 @@ const Search = { htmlToText: (htmlString, anchor) => { const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html'); - for (const removalQuery of [".headerlinks", "script", "style"]) { + for (const removalQuery of [".headerlink", "script", "style"]) { htmlElement.querySelectorAll(removalQuery).forEach((el) => { el.remove() }); } if (anchor) { @@ -328,13 +328,14 @@ const Search = { for (const [title, foundTitles] of Object.entries(allTitles)) { if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) { for (const [file, id] of foundTitles) { - let score = Math.round(100 * queryLower.length / title.length) + const score = Math.round(Scorer.title * queryLower.length / title.length); + const boost = titles[file] === title ? 1 : 0; // add a boost for document titles normalResults.push([ docNames[file], titles[file] !== title ? `${titles[file]} > ${title}` : title, id !== null ? "#" + id : "", null, - score, + score + boost, filenames[file], ]); } diff --git a/getting-started/tutorials/02_construct_simple_pc.html b/getting-started/tutorials/02_construct_simple_pc.html index 0b715b0f..c75c4fdc 100644 --- a/getting-started/tutorials/02_construct_simple_pc.html +++ b/getting-started/tutorials/02_construct_simple_pc.html @@ -111,8 +111,10 @@
In this tutorial, you will learn about the basic APIs to construct PCs.
# sphinx_gallery_thumbnail_path = 'imgs/juice.png'
-
-import torch
+
Let’s start by importing the necessary packages.
+import torch
import pyjuice as juice
import pyjuice.nodes.distributions as dists
This tutorial demonstrates how to construct an HMM with pyjuice.inputs
, pyjuice.multiply
, and pyjuice.summate
.
# sphinx_gallery_thumbnail_path = 'imgs/juice.png'
-
-import torch
+
Let’s start by importing the necessary packages.
+import torch
import pyjuice as juice
import pyjuice.nodes.distributions as dists
In this tutorial, you will learn how to use the built-in structural transformation algorithms to easily create and manipulate PCs.
# sphinx_gallery_thumbnail_path = 'imgs/juice.png'
-
-import torch
+
Let’s start by importing the necessary packages.
+import torch
import pyjuice as juice
import pyjuice.nodes.distributions as dists