-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtutorial.html
198 lines (175 loc) · 9.43 KB
/
tutorial.html
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="author" content="Christian B. Mendl">
<title>GuiTeNet</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-123177817-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'UA-123177817-1');
</script>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-expand navbar-dark bg-dark mb-4">
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="index.html">Home</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Tutorial <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="contribute.html">Contribute</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">About</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="https://github.com/GuiTeNet/guitenet"><img src="images/github.svg" width="36" style="filter: invert(100%);"></a></li>
</ul>
</div>
</nav>
<main role="main" class="container" style="max-width: 45rem;">
<h1>Tutorial</h1>
<p class="lead text-justify">
What are tensors and tensor networks to begin with? A <em>tensor</em> is a generalization
of a matrix, i.e., a multidimensional array. The <em>rank</em> of a tensor is the number of indices
required to label a component. Thus matrices have rank 2 (row and column index), and
vectors have rank 1 (single index for addressing a component). In GuiTeNet, tensors are
abstractly represented as shown in the figure. Each orange leg represents one
dimension; thus, the rank of the tensor in the figure is 4. The zero inside the black
disk serves as unique identification number for the tensor.
</p>
<figure class="figure text-center">
<img src="images/tensor.svg" class="figure-img img-fluid">
<figcaption class="figure-caption text-center">
A single tensor with 4 legs (dimensions); the ordering of dimensions is indicated by the red labels
</figcaption>
</figure>
<p class="lead text-justify">
A <em>tensor network</em> encompasses a collection of tensors together with certain
operations on them, like contractions (which generalize matrix-matrix multiplications)
or splitting of a tensor via so-called SVD or QR-decompositions. Tensor networks (like
for example matrix product states) are an essential framework for the analysis and
simulation of <em>strongly correlated quantum systems</em>; see for example
the <a href="https://arxiv.org/abs/1306.2164">introduction by Orus (2013)</a> or
the <a href="https://arxiv.org/abs/0907.2796">paper by Verstraete, Murg, Cirac (2008)</a>
for a more in-depth introduction, or
the <a href="https://arxiv.org/abs/1008.3477">review by Schollwöck (2011)</a>.
</p>
<p class="lead text-justify">
GuiTeNet facilitates the graphical construction of tensor networks and associated operations,
and simultaneously generates source code for these operations.
</p>
<h2>Create a new tensor</h2>
<p class="lead text-justify">
Add a new tensor to the network by drag-and-dropping the blue circle.
Initially, the new tensor has no legs yet. The blue "create tensor" symbol
reappears at its default location afterwards.
</p>
<figure class="figure">
<img src="images/create_tensor_a.svg" class="figure-img img-fluid"> <span style="font-size: 2em;">»</span>
<img src="images/create_tensor_b.svg" class="figure-img img-fluid"> <span style="font-size: 2em;">»</span>
<img src="images/create_tensor_c.svg" class="figure-img img-fluid">
<figcaption class="figure-caption text-center">Creating a new tensor by a drag-and-drop gesture</figcaption>
</figure>
<h2>Attach tensor legs</h2>
<p class="lead text-justify">
Attach a new leg to a tensor by "pulling" it out of the tensor, i.e.,
drag-and-dropping the tensor and simultaneously holding the <kbd>Shift</kbd> key.
Each tensor and its legs can still be freely moved around within the GUI window.
</p>
<figure class="figure">
<img src="images/create_leg_a.svg" class="figure-img img-fluid"> <span style="font-size: 2em;">»</span>
<img src="images/create_leg_b.svg" class="figure-img img-fluid">
<figcaption class="figure-caption text-center">Attaching a tensor leg</figcaption>
</figure>
<h2>Contract tensors</h2>
<p class="lead text-justify">
Tensor contractions merge tensors together by summing over shared indices, generalizing
matrix-matrix multiplications. Recall that a "conventional" matrix-matrix
multiplication \(C = A B\) is defined as \(c_{ik} = \sum_j a_{ij} b_{jk}\):
the second "leg" (dimension) of \(A\) and the first "leg" (dimension) of \(B\)
are contracted (summed over). The following figure shows a matrix-matrix
multiplication as it appears in GuiTeNet; the matrices \(A\), \(B\) and \(C\)
are the tensors labeled 0, 1 and 2, respectively. The tips of to-be-contracted
(connected) legs change color from green to red.
</p>
<figure class="figure">
<img src="images/matrix_mult_before.svg" class="figure-img img-fluid"> <span style="font-size: 2em;">»</span>
<img src="images/matrix_mult_after.svg" class="figure-img img-fluid">
<figcaption class="figure-caption text-center">Conventional matrix-matrix multiplication</figcaption>
</figure>
<p class="lead text-justify">
A general contraction allows several indices (legs) to be contracted simultaneously.
Specify a contraction by connecting the tips of tensor legs, and click the
"Contract" button to perform the contraction. The output tensor inherits the
free legs (with green tips) from the input tensors; the ordering of these legs
(red labels) follows the identification numbers of the input tensors, that is,
first the free legs of the tensor with the smallest ID, then the free legs of
the tensor with the second smallest ID etc.
</p>
<figure class="figure">
<img src="images/contraction_before.svg" class="figure-img img-fluid"> <span style="font-size: 2em;">»</span>
<img src="images/contraction_after.svg" class="figure-img img-fluid">
<figcaption class="figure-caption text-center">Example of a general tensor network contraction</figcaption>
</figure>
<p class="lead text-justify">
Besides visualizing tensor network operations, GuiTeNet also generates corresponding source code
(currently Python/NumPy, with additional programming languages planned for the future).
Contractions are conveniently translated into NumPy's
<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.einsum.html">einsum</a> function.
For the above example, it reads
</p>
<p>
<pre>T4 = np.einsum(T0, (0, 1, 2), T1, (0, 1, 3), T2, (0, 4), T3, (4, 5), (2, 3, 5))</pre>
</p>
<p class="lead text-justify">
The manuscript (<a href="https://arxiv.org/abs/1808.00532">arXiv:1808.00532</a>) explains the logic
of the code in more detail.
</p>
<h2>Split a tensor</h2>
<p class="lead text-justify">
Splitting a tensor by a so-called QR or singular value decomposition (SVD) is
a ubiquitous operation in tensor network algorithms. The first step is the
"matricization" of the tensor: a subset of legs is grouped together into one
"fat" leg and the remaining (complementary) legs into a second "fat" leg.
The two fat legs are interpreted as the rows and columns of a matrix, which is
then decomposed.
</p>
<p class="lead text-justify">
The figure below illustrates this process (as it appears in GuiTeNet)
for the QR decomposition of a tensor with initially 5 legs.
First right-click on a tensor to initiate the splitting operation. An overlay
window then asks for the ordering and partitioning of dimensions attributed to
the rows and columns in the matricization process. In the example, the "row"
consists of dimensions 0, 3, 2 (in this order) and the "column" of dimensions
1, 4 (in this order). After the decomposition, the resulting Q and R matrices are
finally reshaped to restore the original dimensions, with an additional dimension
for the shared bond (last dimension of Q, first dimension of R). Thus the dimensions
0, 1, 2 of Q match the original dimensions 0, 3, 2, and dimensions 1, 2 of R the
original dimensions 1, 4.
</p>
<figure class="figure">
<img src="images/qr_splitting_input.svg" class="figure-img img-fluid"> <span style="font-size: 2em;">»</span>
<img src="images/qr_splitting_params.svg" class="figure-img img-fluid"> <span style="font-size: 2em;">»</span>
<img src="images/qr_splitting_result.svg" class="figure-img img-fluid">
<figcaption class="figure-caption text-center">QR splitting of a tensor, arranging the dimensions attributed to the Q and R tensors in the overlay window</figcaption>
</figure>
</main>
<p class="lead text-right">
<a href="#" class="btn btn-outline-primary" role="button">↟</a>
</p>
<!-- MathJax -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script>
</body>
</html>