TensorNetwork / tensornetwork.org

Source for The Tensor Network open-source review article
https://tensornetwork.org
Apache License 2.0
150 stars 52 forks source link

Tensor diagram notation graphics #4

Closed stared closed 5 years ago

stared commented 5 years ago

How did you create these diagrams?

I did create some (e.g. the one in Matrix product state Wikipedia page; I did my PhD in quantum physics), but nothing nearly as visually pleasing. I've found them nice (vide https://medium.com/@pmigdal/in-the-topic-of-diagrams-i-did-write-a-review-simple-diagrams-of-convoluted-neural-networks-6418a63f9281).

Moreover, I write "thinking in tensors, writing in PyTorch" and want to introduce a (technical) general audience to these diagrams. Such diagrams (also with examples from other disciplines), would be useful... and visually pleasing.

emstoudenmire commented 5 years ago

Hi, good question, although you may be disappointed with the answer. So far I've just been creating the diagrams in Apple Keynote. I'm glad you like the style; it's just a drawing style I developed after working with this notation for quite a while.

I'd be happy to post or send you the Keynote file containing the graphics from the tensornetwork.org site if you want to use it as sort of a template for making your own (assuming you have a Mac!).

My colleagues at Flatiron Institute and I are pursuring hiring someone to make software for drawing these diagrams, and for converting diagrams into code that can actually be run (in various tensor network software libraries).

I really like the idea of using this notation in other fields; for example, I taught myself how kernel learning (SVM theory) works by writing out the equations diagrammatically, and it was very helpful.

stared commented 5 years ago

I do have a Mac, though I was looking for more for a tool.

In any case, here is a quick&dirty version in D3.js:

screenshot 2019-01-31 13 03 30

Code: https://jsfiddle.net/stared/8huz5gy7/

It does not cover all cases (fundamentally: tensor products, co- vs contravariant indices). If you want to adjust shapes, colors lengths and font sizes, I would be grateful. And I would be open for collaboration, is needed.

Since I use your style - is it fine if I use it in the current form in my materials?

emstoudenmire commented 5 years ago

Hi Piotr, this looks really great! Regarding the code, is it intended as a prototype of a system one could use to quickly make new diagrams? If so, which part of that code would one change? Thanks -

Yes, I’d be happy to collaborate on something like this with you, if you don’t mind my involvement being mostly limited to discussing what would be most useful and what a good interface / input format etc. would be. I may not have time to get into the code itself with you, though I might if I do find some time.

About the style, I wouldn’t really say it’s “my” style so much, since it’s a fairly standard notation across the tensor network literature. But I have found the format of colored shapes with a black, 4px border and 4px lines to be one that looks good across many different formats and background etc.