Plotting with Torch7

Bokeh / iTorch

Bokeh is a Python interactive visualization library that use modern web browsers to display plots. It can be highly interactive and it can plot barely everything in a pretty way. In a few words, it looks perfect.

A Bokeh wrapper is implemented in the iTorch Framework. First I was very enthusiastic since the interface is clean and Tensor are really well integrated. However, only the most basic features are wrapped. A small number of charts are available and few interaction are allowed on the plots. Maybe, I misused the library but it looks like a lot of features are hard-coded.

Nevertheless, Bokeh/iTorch is still a good alternative for beginners. The Lua interface is way more-user friendly than NVD3 or dygraph!

  • Lua API :
  • Underlying API :

                  By default, you need to use either iTorch and its notebook or to save the html in a file.


                  Yet, by tricking a bit the API, it is possible to display the plots in a gfx server. I found this solution more user friendly


                  Some tricks to know:

                  • One cannot simply throw the baby out with the bathwater. iTorch plotting abilities are likely to evolve. Some charts are only available with bokeh such as quiver or quad.
                  • The redraw method is very nice to dynamically upgrade figures

                  3 Comments on “Plotting with Torch7

                  1. Great,
                    I would like to ask if there is a way how to compute Recall and precision from a confusion matrix and draw them if it is possible. I am facing this problem for more than a month but I could not find an answer. So, please help.

                    • Sure!
                      First, you can compute your confusion matrix my using the optim package:

                      Then, if you want to plot accuracy/recall upon time, Dygraph/Display is a good library

                      For every steps:
                      – Compute the Precision/Recall from your confusion matrix
                      \text{Precision}=\frac{tp}{tp+fp} \,
                      \text{Recall}=\frac{tp}{tp+fn} \,

                      – Plot it !

                      Lua code:

                      local labels = {"epoch", 'accuracy', 'recall'}
                      local data = {}

                      local config =
                      title = "Global accuracy/recall upon time",
                      labels = labels,
                      ylabel = "ratio",

                      for t = 1, noEpoch do

                      local accuracy, recall = someFct()

                      table.insert(data, {t, accuracy, recall })

                      -- display
             = disp.plot(data, config)


                      • Hi
                        Many thanks for replying but I try it many times but did not work with. Could you please give me more intuition about the code.

                  Leave a Reply

                  Your email address will not be published.