-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Equality checking for tensor objects #252
Comments
Hi @ACE07-Sev, thanks for the issue. I think the solution here is probably a special method for the specific type of equality checking you want e.g. I actully didn;y realize that The problem with implementing
E.g. for 1. what tolerance should be used ? and for 3., an extra wrinkle is this becomes a NP-hard problem to check if the two graphs of a tensor network are equivalent. Some already implemented methods that might be of interest:
|
Greetings there dear Johnnie, Hope you are well. Thank you very much for the prompt response, sir! So, my suggestion would be to check the equality of the tensor data (the underlying numpy arrays) and the structure. Basically, do not check the equality of I mean, a tensor network is basically an NDArray correct? We only care about the structure (shape) and element-wise values. The purpose for me personally was to check if two I would say instead of disabling |
I don't think this would be a good fit for tna.geometry_hash(strict_index_order=True) == tnb.geometry_hash(strict_index_order=True) and all(do('allclose', x, y, **allclose_opts) for x, y in zip(tna.arrays, tnb.arrays) and call it
A TN represents a NDArray, but the element-wise values are not known until contracted. Moreover the actual values depend on the network geometry, which one can arbitrarily permute, and there is also a gauge freedom meaning you can transform all the arrays in the TN without changing the overall object represented. For these reasons if you implemented My preference here would be to disable
|
Greetings there, Hope you are well sir. Apologies for the delay. May I ask what |
Is your feature request related to a problem?
At the moment, as far as I can tell, the tensor network objects don't have any implementations for
__eq__
, which results in python using the standard__eq__
from thebuiltins
module. The issue is that this will not work properly given it would require every attribute to be equal.For tensors and tensor networks, we only need to ensure the underlying tensor data (the matrices, shapes, and number of sites) are equal. The index string generation may cause different
str
values for identical indices. i.e.,And if you re-run the exact same thing, you may get a different MPS instance
Which will cause in the equality to fail.
Describe the solution you'd like
I am still quite new to
quimb
, but I believe implementing the__eq__
such that the underlying tensor data (the matrices) are equal should suffice. Essentially, do not require theinds
to be equal since the string generation is not consistent.Describe alternatives you've considered
The issue given I haven't made any mistakes in understanding (hopefully) is quite easy to fix. I don't think any other alternatives would be needed besides a concrete implementation of
__eq__
dunder in the relevant base class (I imagine it would beTensorNetwork
, or even justTensor
sinceTensorNetwork
'stensors
property is just a container ofTensor
instances iirc).Additional context
No response
The text was updated successfully, but these errors were encountered: