Skip to content

Commit

Permalink
Deploying to gh-pages from @ db3460c 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
liuanji committed Jul 17, 2024
1 parent 1ee1b42 commit 84c79f2
Show file tree
Hide file tree
Showing 50 changed files with 166 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .buildinfo
Original file line number Diff line number Diff line change
@@ -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
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Binary file modified .doctrees/getting-started/tutorials/02_construct_simple_pc.doctree
Binary file not shown.
Binary file modified .doctrees/getting-started/tutorials/03_construct_hmm.doctree
Binary file not shown.
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.blockify.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.compile.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.deepcopy.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.inputs.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.load.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.merge.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.multiply.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.nodes.InputNodes.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.nodes.ProdNodes.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.nodes.SumNodes.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.nodes.foreach.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.save.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.set_block_size.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.structures.HCLT.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.structures.HMM.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.structures.PD.doctree
Binary file not shown.
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.summate.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/generated/pyjuice.unblockify.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/nodes.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/pyjuice.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/structures.doctree
Binary file not shown.
Binary file modified .doctrees/python-api/tensorcircuit.doctree
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified _downloads/662999063954282841dc90b8945f85ce/tutorials_jupyter.zip
Binary file not shown.
Binary file modified _downloads/763344228ae6bc253ed1a6cf586aa30d/tutorials_python.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 26 additions & 16 deletions _sources/getting-started/tutorials/02_construct_simple_pc.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,51 @@ 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
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`.

Expand All @@ -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
Expand All @@ -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]`.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand Down
30 changes: 20 additions & 10 deletions _sources/getting-started/tutorials/03_construct_hmm.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,37 +59,37 @@ 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
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
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
Expand Down Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 84c79f2

Please sign in to comment.