-
I've been using the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi @cotejer, Depending on what geometry you have (?), e.g. a tree or MPS, then you would probably want to take a more systematic approach where you shift the 'orthogonality center' around, and therefore use the ideal environment for each compression. Here's a method (not pushed to def compress_all_tree(self, inplace=False, **compress_opts):
"""Canonically compress this tensor network, assuming it to be a tree.
This generates a tree spanning out from the most central tensor, then
compresses all bonds inwards in a depth-first manner, using an infinite
``canonize_distance`` to shift the orthogonality center.
"""
tn = self if inplace else self.copy()
# order out spanning tree by depth first search
def sorter(t, tn, distances, connectivity):
return distances[t]
tid0 = tn.most_central_tid()
span = tn.get_tree_span([tid0], sorter=sorter)
for tid1, tid2, _ in span:
# absorb='right' shifts orthog center inwards
tn._compress_between_tids(
tid1, tid2, absorb='right',
canonize_distance=float('inf'), **compress_opts)
return tn However if your TN is not a tree (i.e. has loops) then the best way to compress becomes quite a non-trivial problem. |
Beta Was this translation helpful? Give feedback.
-
@jcmgray Thanks for the explanation. In my case, I could have loops. If I understand correctly, is |
Beta Was this translation helpful? Give feedback.
Hi @cotejer,
compress_all
is quite a basic function that assumes no particular geometry and simply takes every bond in the tensor network, in any order, and compresses between the two tensors. How well the compression works always depends on the environment of the tensors.Depending on what geometry you have (?), e.g. a tree or MPS, then you would probably want to take a more systematic approach where you shift the 'orthogonality center' around, and therefore use the ideal environment for each compression. Here's a method (not pushed to
quimb
yet..) that could do that automatically.