Giter Club home page Giter Club logo

itensorsvisualization.jl's Introduction

⚠️ INFO: This repository is deprecated

The functionality of ITensorsVisualization has been moved into the monorepo at ITensors.jl. For the latest ITensor visualization functionality, use particular backend packages such as ITensorUnicodePlots or ITensorGLMakie.

ITensorsVisualization

This is a package for visualizing tensor networks. The main purpose is to use it with the ITensors.jl package to view and debug tensor network contractions, for example:

using ITensors
using ITensorsVisualization

i = Index(2, "index_i")
j = Index(10, "index_j")
k = Index(40, "index_k")
l = Index(40, "index_l")
m = Index(40, "index_m")
A = randomITensor(i, j, k)
B = randomITensor(i, j, l, m)
C = randomITensor(k, l)
# Contract the tensors over the common indices
# and visualize the results
ABC = @visualize A * B * C

A window like the following should appear:

alt text

The visualization makes an initial guess for the locations of the tensors (using NetworkLayout.jl), and then allows users to interactively move the tensors to better locations. You can move the tensors and external indices (the square and circle nodes of the network) by left clicking on a node and dragging it to a new location. You can also right click and drag to translate the entire diagram, and scroll to zoom in and out.

In addition, you can pause the execution between contractions to analyze intermediate results:

julia> AB = @visualize A * B pause = true; ABC = @visualize AB * C;
Press C/c and then Enter to continue:
c

This will first visualize the contraction A * B, wait for the user to respond, and then perform the contraction and continue to visualize and perform contraction AB * C. This is helpful for viewing and debugging multistep contractions.

alt text alt text

itensorsvisualization.jl's People

Contributors

mtfishman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

itensorsvisualization.jl's Issues

Add option to not throw an error for an arrow mismatch

Currently for QN ITensors, @visualize will throw an error that the index directions don't match. However, for debugging purposes, it would be helpful to turn off that check (and maybe even visually indicate where an index direction mismatch occurred). This could be turned on and off with a keyword argument like checkdir, i.e. @visualize A * B * C checkdir = false. Note that the contraction, if it is performed (i.e. of contract = true), will still catch the index direction mismatch. Probably checkdir should be off by default, since most of the time it is helpful to debug that kind of issue visually.

Alternatives for the backend

I downloaded this package and played around with it for a while, but I feel GLMakie might not be the best choice for the backend.
It is slow to first plot, and can not embed the image inside a Pluto notebook.
There are some alternatives that you might be interested.

Compose.jl

Pros
  • very fast first plot, the following is the using time
(base) ➜  ~ time julia -e "using Compose"
julia -e "using Compose"  0.83s user 0.56s system 182% cpu 0.762 total
(base) ➜  ~ time julia -e "using GLMakie"
julia -e "using GLMakie"  4.95s user 0.74s system 108% cpu 5.226 total
(base) ➜  ~ time julia -e "using Luxor"  
julia -e "using Luxor"  1.02s user 0.62s system 158% cpu 1.032 total
  • Compatible with Pluto notebook with native support to SVG format,
    The following is an example of my notebook, one can embed the image to the notebook.

Cons
  • no latex support
  • maintained by the community (or not actively maintained anymore)

Luxor.jl

Pros
  • very fast first plot,
  • Good documentation and is more actively maintained than Compose.jl
Cons
  • no latex support

NOTE:

I am currently using Compose for showing networks (https://github.com/GiggleLiu/Viznet.jl).
I feel its functionality is good, but the Compose API is not quite user friendly. Maybe Luxor is the best choice.
Both do not have a proper latex support, this is the pain point. But I guess it is not too hard to add the MathJax support for Compose so that it can display latex in Pluto notebooks and other web applications.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.