Comments (9)
Oof. That looks like a false assumption about singular value ordering?
from tensornetwork.
I think it's likely an off by one in the cumsum slicing. I'll investigate it tonight.
from tensornetwork.
Ah, I misread. Actually, I think this is working as intended! What you are calling truncation_error
is a vector of the discarded singular values, so the truncation error is actually tf.norm(truncation_error)
, which is 2.5 in this case.
from tensornetwork.
I'm a bit confused by the meaning of max_truncation_err
. I would expect that a value of e.g.
max_truncation_err=0.4
would mean that you discard the smallest n
singular values of s
such that (fors
ordered from large to small)sum(s[n:])<=max_truncation_err
. the following code though does something different:
diag = np.sort(np.arange(10).astype(np.float64))
diag /= np.linalg.norm(diag)
print(diag[::-1])
diagonal_array = np.diag(diag)
net = tensornetwork.TensorNetwork()
a = net.add_node(diagonal_array)
u, vh, truncation_error = net.split_node(
a, left_edges=[a[0]], right_edges=[a[1]], max_truncation_err=0.4)
print(np.sum(truncation_error.numpy()))
print(truncation_error.numpy())
which outputs
[0.53311399 0.4738791 0.41464421 0.35540933 0.29617444 0.23693955
0.17770466 0.11846978 0.05923489 0. ]
0.5923488777590923
[0.23693955 0.17770466 0.11846978 0.05923489 0. ]
what is the rationale behind this?
from tensornetwork.
Yeah I agree with Martin. It would make more sense if sum(trun_err) <= max_truncation_err
, the norm
doesn't feel natural.
from tensornetwork.
OK I see. It actually depends on the norm you would like to use to compare the truncated and the original matrix. The current implementation uses L2, which is the one we usually use in our tensor network implementations. We could add a flag that allows the user to choose the norm. In any case, we should the convention to the documentation of split_node
, because this might confuse people.
from tensornetwork.
@mganahl Yes. It's mentioned that "the norm" is used in the documentation for the svd decomposition, but it should definitely be made clearer.
It would be cool to have the norm configurable! The infinity norm would also be an intuitive choice (truncate so that np.max(discarded_singular_values) <= max_truncation_err
). We could use a cumnorm(x, ord=...)
op.
from tensornetwork.
Sounds good! The documentation of split_node()
only says max_truncation_err: The maximum allowed truncation error
, but we should say that we are using the L2 norm (or equivalently Hilbert-Schmidt norm for matrices), i.e. something like
max_truncation_err: The maximum allowed truncation error as measured by the Hilbert-Schmidt norm
. I can add it to my latest PR if that's not too confusing.
from tensornetwork.
I agree let's improve the documentation. Though I'd rather you do it in a separate PR
from tensornetwork.
Related Issues (20)
- Flaky Test when seed not used HOT 5
- Flaky test (always fails) when seeds are removed HOT 1
- Test `test_gmres_on_larger_random_problem` fails without seeds
- symmetric backend very slow for PEPS tensors HOT 4
- Home Network
- lack sqrt operation in tensornetwork/matrixproductstates/infinite_mps.py
- TensorNetwork backend for QuTiP. HOT 2
- Bug for numpy backend ``sum`` method HOT 3
- SVD on jax backend and thus ``split_node`` cannot be jitted when ``max_truncation_err`` is set
- Bug of setting `center_position` in `apply_two_site_gate` when there's no truncation
- Quantum hardware system integration with TensorNetwork
- Missing code for TensorNetwork Machine Learning HOT 1
- `backend.item` in MPS calculation is incompatible with autograd in jax HOT 2
- The lack of tensor-train RNNs for latest tf/keras HOT 1
- Parallelism Contractors HOT 1
- Question: Vector to FiniteMPS?
- Is there a simple way to multiply a scalar to the tensor values of a node that is part of a network of tensors? HOT 2
- Maintenance of this repository HOT 3
- Tensor
- Pf
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tensornetwork.