TensorNetwork icon indicating copy to clipboard operation
TensorNetwork copied to clipboard

Renaming NconBuilder and related

Open chaserileyroberts opened this issue 5 years ago • 13 comments

We should consider renaming the methods around NconBuilder.

Current changes proposed: NconBuilder -> ContractionBuilder tn.contract -> tn.contract_edge tn.finalize -> tn.contract

chaserileyroberts avatar Nov 02 '20 16:11 chaserileyroberts

#869

chaserileyroberts avatar Nov 02 '20 16:11 chaserileyroberts

Well, I think it's a good idea. I personally think I would prefer this API in my own work, which is admittedly fairly MPS-centric.

I also like the opportunity it gives to abstract contractions so they can be manipulated and so on independently of the concrete tensors. I wonder if we can invent convenient functions to generate e.g. reflections of contractions:

given

|----
A-B-
|----

return

   --|
---B-A
   --|

alewis avatar Nov 03 '20 14:11 alewis

Ok well I can't get the bottom one to come out right but hopefully you get the idea. Not sure if it's feasible.

alewis avatar Nov 03 '20 14:11 alewis

tn.conj?

chaserileyroberts avatar Nov 03 '20 14:11 chaserileyroberts

I would stick to conj and transpose for that.

mganahl avatar Nov 03 '20 14:11 mganahl

Sorry, what I mean is that the function would be transpose, not the output tensor

alewis avatar Nov 03 '20 16:11 alewis

I don't understand what you mean.

chaserileyroberts avatar Nov 03 '20 17:11 chaserileyroberts

Well that's cause the idea is a bit half-baked:

-eventually we could use Contraction/NconBuilder to create "Contraction" objects which do the specified ncon call -having done that one could also imagine functions acting on the tn.Contraction before it is actually used. For example, reflecting the specified tensor network about an axis, permuting the output, removing one of the tensors or adding a new one.

On Tue, Nov 3, 2020 at 12:27 PM Chase Roberts [email protected] wrote:

I don't understand what you mean.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/google/TensorNetwork/issues/871#issuecomment-721270676, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAINHBUIOJUV7PCEMMRSFPTSOA4PRANCNFSM4THWZZ5A .

alewis avatar Nov 03 '20 19:11 alewis

I really like this idea. We could use NconBuilder as a "shell" tensor network class that Glen was proposing a few months back. The NconBuilder could for example store metadata about contraction orders and the like. In that case it would be useful to be able to replace the current tensors in the builder with new ones. For complicated algorithms, reusing the network structure with different tensors is sometimes useful.

In a way, this would be similar to the early TensorNetwork object we had, but easier to build.

mganahl avatar Nov 03 '20 21:11 mganahl

You could not live with your own failed OO design. And where did that bring you? Back to me.

-- The TensorNetwork class

chaserileyroberts avatar Nov 03 '20 21:11 chaserileyroberts

And I like all these ideas. My only request is that the NconBuilder remains functional. (Immutable, functions have no side effects)

chaserileyroberts avatar Nov 03 '20 21:11 chaserileyroberts

absolutely agree

mganahl avatar Nov 03 '20 22:11 mganahl

You could not live with your own failed OO design. And where did that bring you? Back to me.

-- The TensorNetwork class

lol

mganahl avatar Nov 03 '20 22:11 mganahl