Skip to content

Commit c7245bd

Browse files
author
Documenter.jl
committed
build based on d914583
1 parent 9e69ad5 commit c7245bd

File tree

8 files changed

+63
-63
lines changed

8 files changed

+63
-63
lines changed

dev/.documenter-siteinfo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"documenter":{"julia_version":"1.11.5","generation_timestamp":"2025-05-12T11:23:09","documenter_version":"1.11.0"}}
1+
{"documenter":{"julia_version":"1.11.5","generation_timestamp":"2025-05-12T11:23:42","documenter_version":"1.11.0"}}

dev/api/internal/index.html

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

dev/api/public/index.html

Lines changed: 29 additions & 29 deletions
Large diffs are not rendered by default.

dev/generated/asia-network/main/index.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
Factor(6, 7), size = (2, 2)
2525
Factor(5, 6, 8), size = (2, 2, 2)</code></pre><hr/><p>Create a tensor network representation of the loaded model.</p><pre><code class="language-julia hljs">tn = TensorNetworkModel(model)</code></pre><pre><code class="nohighlight hljs">TensorNetworkModel{OMEinsum.DynamicNestedEinsum{Int64}, Array{Float64}}
2626
variables: 1, 2, 3, 4, 5, 6, 7, 8
27-
contraction time = 2^6.044, space = 2^2.0, read-write = 2^7.098</code></pre><hr/><p>Calculate the partition function. Since the factors in this model are normalized, the partition function is the same as the total probability, <span>$1$</span>.</p><pre><code class="language-julia hljs">probability(tn) |&gt; first</code></pre><pre><code class="nohighlight hljs">1.0</code></pre><hr/><p>Calculate the marginal probabilities of each random variable in the model.</p><pre><code class="language-julia hljs">marginals(tn)</code></pre><pre><code class="nohighlight hljs">Dict{Vector{Int64}, Vector{Float64}} with 8 entries:
27+
contraction time = 2^6.087, space = 2^2.0, read-write = 2^7.14</code></pre><hr/><p>Calculate the partition function. Since the factors in this model are normalized, the partition function is the same as the total probability, <span>$1$</span>.</p><pre><code class="language-julia hljs">probability(tn) |&gt; first</code></pre><pre><code class="nohighlight hljs">1.0</code></pre><hr/><p>Calculate the marginal probabilities of each random variable in the model.</p><pre><code class="language-julia hljs">marginals(tn)</code></pre><pre><code class="nohighlight hljs">Dict{Vector{Int64}, Vector{Float64}} with 8 entries:
2828
[8] =&gt; [0.435971, 0.564029]
2929
[3] =&gt; [0.5, 0.5]
3030
[1] =&gt; [0.01, 0.99]
@@ -42,18 +42,18 @@
4242
7
4343
8</code></pre><hr/><p>Set the evidence: Assume that the &quot;X-ray&quot; result (variable 7) is negative. Since setting the evidence may affect the contraction order of the tensor network, recompute it.</p><pre><code class="language-julia hljs">tn = TensorNetworkModel(model, evidence = Dict(7 =&gt; 0))</code></pre><pre><code class="nohighlight hljs">TensorNetworkModel{OMEinsum.DynamicNestedEinsum{Int64}, Array{Float64}}
4444
variables: 1, 2, 3, 4, 5, 6, 7 (evidence → 0), 8
45-
contraction time = 2^6.044, space = 2^2.0, read-write = 2^7.109</code></pre><hr/><p>Calculate the maximum log-probability among all configurations.</p><pre><code class="language-julia hljs">maximum_logp(tn)</code></pre><pre><code class="nohighlight hljs">0-dimensional Array{Float64, 0}:
45+
contraction time = 2^6.0, space = 2^2.0, read-write = 2^7.066</code></pre><hr/><p>Calculate the maximum log-probability among all configurations.</p><pre><code class="language-julia hljs">maximum_logp(tn)</code></pre><pre><code class="nohighlight hljs">0-dimensional Array{Float64, 0}:
4646
-3.6522217920023303</code></pre><hr/><p>Generate 10 samples from the posterior distribution.</p><pre><code class="language-julia hljs">sample(tn, 10)</code></pre><pre><code class="nohighlight hljs">10-element TensorInference.Samples{Int64}:
47-
[1, 1, 0, 0, 0, 0, 0, 0]
47+
[1, 1, 0, 0, 1, 0, 0, 0]
4848
[1, 1, 0, 1, 0, 1, 0, 1]
49-
[1, 1, 0, 0, 0, 0, 0, 1]
49+
[1, 0, 1, 1, 0, 0, 0, 0]
50+
[1, 1, 0, 1, 1, 1, 0, 1]
51+
[1, 1, 0, 0, 0, 0, 0, 0]
5052
[1, 1, 0, 1, 0, 1, 0, 0]
51-
[1, 1, 0, 0, 1, 0, 0, 0]
52-
[1, 1, 0, 1, 1, 1, 0, 0]
53-
[1, 1, 0, 0, 1, 0, 0, 1]
54-
[1, 1, 0, 1, 1, 1, 0, 0]
53+
[1, 0, 0, 1, 1, 0, 0, 0]
5554
[1, 1, 0, 0, 0, 0, 0, 0]
56-
[1, 1, 0, 0, 1, 0, 0, 1]</code></pre><hr/><p>Retrieve both the maximum log-probability and the most probable configuration.</p><pre><code class="language-julia hljs">logp, cfg = most_probable_config(tn)</code></pre><pre><code class="nohighlight hljs">(-3.6522217920023303, [1, 1, 0, 0, 0, 0, 0, 0])</code></pre><hr/><p>Compute the most probable values of certain variables (e.g., 4 and 7) while marginalizing over others. This is known as Maximum a Posteriori (MAP) estimation.</p><pre><code class="language-julia hljs">mmap = MMAPModel(model, evidence=Dict(7=&gt;0), queryvars=[4,7])</code></pre><pre><code class="nohighlight hljs">MMAPModel{Int64, Array{Float64}}
55+
[1, 1, 0, 0, 1, 0, 0, 0]
56+
[1, 0, 1, 1, 1, 0, 0, 0]</code></pre><hr/><p>Retrieve both the maximum log-probability and the most probable configuration.</p><pre><code class="language-julia hljs">logp, cfg = most_probable_config(tn)</code></pre><pre><code class="nohighlight hljs">(-3.6522217920023303, [1, 1, 0, 0, 0, 0, 0, 0])</code></pre><hr/><p>Compute the most probable values of certain variables (e.g., 4 and 7) while marginalizing over others. This is known as Maximum a Posteriori (MAP) estimation.</p><pre><code class="language-julia hljs">mmap = MMAPModel(model, evidence=Dict(7=&gt;0), queryvars=[4,7])</code></pre><pre><code class="nohighlight hljs">MMAPModel{Int64, Array{Float64}}
5757
variables: 4, 7 (evidence → 0)
5858
query variables: 4
59-
contraction time = 2^6.0, space = 2^2.0, read-write = 2^7.0</code></pre><hr/><p>Get the most probable configurations for variables 4 and 7.</p><pre><code class="language-julia hljs">most_probable_config(mmap)</code></pre><pre><code class="nohighlight hljs">(-2.8754627318176693, [1, 0])</code></pre><hr/><p>Compute the total log-probability of having lung cancer. The results suggest that the probability is roughly half.</p><pre><code class="language-julia hljs">log_probability(mmap, [1, 0]), log_probability(mmap, [0, 0])</code></pre><pre><code class="nohighlight hljs">(-2.8754627318176693, -2.9206248010671856)</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p><section class="footnotes is-size-7"><ul><li class="footnote" id="footnote-lauritzen1988local"><a class="tag is-link" href="#citeref-lauritzen1988local">lauritzen1988local</a>Steffen L Lauritzen and David J Spiegelhalter. Local computations with probabilities on graphical structures and their application to expert systems. <em>Journal of the Royal Statistical Society: Series B (Methodological)</em>, 50(2):157–194, 1988.</li></ul></section></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../../../examples-overview/">« Overview</a><a class="docs-footer-nextpage" href="../../hard-core-lattice-gas/main/">Hard-core Lattice Gas »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.11.0 on <span class="colophon-date" title="Monday 12 May 2025 11:23">Monday 12 May 2025</span>. Using Julia version 1.11.5.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
59+
contraction time = 2^6.022, space = 2^2.0, read-write = 2^7.033</code></pre><hr/><p>Get the most probable configurations for variables 4 and 7.</p><pre><code class="language-julia hljs">most_probable_config(mmap)</code></pre><pre><code class="nohighlight hljs">(-2.8754627318176693, [1, 0])</code></pre><hr/><p>Compute the total log-probability of having lung cancer. The results suggest that the probability is roughly half.</p><pre><code class="language-julia hljs">log_probability(mmap, [1, 0]), log_probability(mmap, [0, 0])</code></pre><pre><code class="nohighlight hljs">(-2.8754627318176693, -2.920624801067186)</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p><section class="footnotes is-size-7"><ul><li class="footnote" id="footnote-lauritzen1988local"><a class="tag is-link" href="#citeref-lauritzen1988local">lauritzen1988local</a>Steffen L Lauritzen and David J Spiegelhalter. Local computations with probabilities on graphical structures and their application to expert systems. <em>Journal of the Royal Statistical Society: Series B (Methodological)</em>, 50(2):157–194, 1988.</li></ul></section></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../../../examples-overview/">« Overview</a><a class="docs-footer-nextpage" href="../../hard-core-lattice-gas/main/">Hard-core Lattice Gas »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.11.0 on <span class="colophon-date" title="Monday 12 May 2025 11:23">Monday 12 May 2025</span>. Using Julia version 1.11.5.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>

dev/generated/hard-core-lattice-gas/main/index.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
β = 3.0
1414
pmodel = TensorNetworkModel(problem, β)</code></pre><pre><code class="nohighlight hljs">TensorNetworkModel{OMEinsum.DynamicNestedEinsum{Int64}, Array{Float64}}
1515
variables: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100
16-
contraction time = 2^17.483, space = 2^12.0, read-write = 2^15.494</code></pre><p>The partition function of this statistical model can be computed with the <a href="../../../api/public/#TensorInference.probability"><code>probability</code></a> function.</p><pre><code class="language-julia hljs">partition_func = probability(pmodel)</code></pre><pre><code class="nohighlight hljs">exp(107.42267890429403) * fill(1.0)</code></pre><p>The default return value is a log-rescaled tensor. Use indexing to get the real value.</p><pre><code class="language-julia hljs">partition_func[]</code></pre><pre><code class="nohighlight hljs">4.4985927541462117e46</code></pre><p>The marginal probabilities can be computed with the <a href="../../../api/public/#TensorInference.marginals"><code>marginals</code></a> function, which measures how likely a site is occupied.</p><pre><code class="language-julia hljs">mars = marginals(pmodel)
16+
contraction time = 2^17.654, space = 2^11.0, read-write = 2^15.611</code></pre><p>The partition function of this statistical model can be computed with the <a href="../../../api/public/#TensorInference.probability"><code>probability</code></a> function.</p><pre><code class="language-julia hljs">partition_func = probability(pmodel)</code></pre><pre><code class="nohighlight hljs">exp(107.42267890429402) * fill(1.0)</code></pre><p>The default return value is a log-rescaled tensor. Use indexing to get the real value.</p><pre><code class="language-julia hljs">partition_func[]</code></pre><pre><code class="nohighlight hljs">4.4985927541461473e46</code></pre><p>The marginal probabilities can be computed with the <a href="../../../api/public/#TensorInference.marginals"><code>marginals</code></a> function, which measures how likely a site is occupied.</p><pre><code class="language-julia hljs">mars = marginals(pmodel)
1717
show_graph(SimpleGraph(graph), sites; vertex_colors=[(b = mars[[i]][2]; (1-b, 1-b, 1-b)) for i in 1:nv(graph)], texts=fill(&quot;&quot;, nv(graph)))</code></pre><p><img src="../main-16.svg" alt/></p><p>The can see the sites at the corner is more likely to be occupied. To obtain two-site correlations, one can set the variables to query marginal probabilities manually.</p><pre><code class="language-julia hljs">pmodel2 = TensorNetworkModel(problem, β; unity_tensors_labels = [[e.src, e.dst] for e in edges(graph)])
1818
mars = marginals(pmodel2);</code></pre><p>We show the probability that both sites on an edge are not occupied</p><pre><code class="language-julia hljs">show_graph(SimpleGraph(graph), sites; edge_colors=[(b = mars[[e.src, e.dst]][1, 1]; (1-b, 1-b, 1-b)) for e in edges(graph)], texts=fill(&quot;&quot;, nv(graph)), config=GraphDisplayConfig(; edge_line_width=5))</code></pre><p><img src="../main-20.svg" alt/></p><h2 id="The-most-likely-configuration"><a class="docs-heading-anchor" href="#The-most-likely-configuration">The most likely configuration</a><a id="The-most-likely-configuration-1"></a><a class="docs-heading-anchor-permalink" href="#The-most-likely-configuration" title="Permalink"></a></h2><p>The MAP and MMAP can be used to get the most likely configuration given an evidence. The relavant function is <a href="../../../api/public/#TensorInference.most_probable_config"><code>most_probable_config</code></a>. If we fix the vertex configuration at one corner to be one, we get the most probably configuration as bellow.</p><pre><code class="language-julia hljs">pmodel3 = TensorNetworkModel(problem, β; evidence=Dict(1=&gt;1))
1919
mars = marginals(pmodel3)
@@ -46,15 +46,15 @@
4646
0
4747
0
4848
0
49-
1
50-
8
49+
0
50+
5
5151
23
52-
71
53-
135
54-
175
55-
185
56-
211
57-
129
58-
58
59-
4
52+
77
53+
110
54+
196
55+
225
56+
183
57+
112
58+
54
59+
15
6060
0</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../../asia-network/main/">« Asia Network</a><a class="docs-footer-nextpage" href="../../../performance-evaluation/">Performance evaluation »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.11.0 on <span class="colophon-date" title="Monday 12 May 2025 11:23">Monday 12 May 2025</span>. Using Julia version 1.11.5.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>

0 commit comments

Comments
 (0)