TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
Public Member Functions | List of all members
visdom::Visdom Class Reference

#include <visdom.h>

Public Member Functions

 Visdom (ConnectionParams cparams=ConnectionParams(), std::string env="main", bool send=true)
 
 ~Visdom ()
 
std::string save (std::vector< std::string > const &envs)
 This funciton allows the user to save envs that are alive on the Tornado server. More...
 
std::string close (std::string const &win=std::string(), std::string const &env=std::string())
 This function closes a specific window. More...
 
std::string text (std::string const &txt, Options const &opts=Options())
 This funciton prints text in a box. More...
 
std::string text (std::string const &txt, std::string const &win, Options const &opts=Options())
 
std::string text (std::string const &txt, std::string const &win, std::string const &env, Options const &opts=Options())
 
std::string heatmap (torch::Tensor tensor, Options const &opts=Options())
 This function draws a heatmap. More...
 
std::string heatmap (torch::Tensor tensor, std::string const &win, Options const &opts=Options())
 
std::string heatmap (torch::Tensor tensor, std::string const &win, std::string const &env, Options const &opts=Options())
 
std::string scatter (torch::Tensor X, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 This function draws a 2D or 3D scatter plot. More...
 
std::string scatter (torch::Tensor X, std::string const &win, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 
std::string scatter (torch::Tensor X, std::string const &win, std::string const &env, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 
std::string scatter (torch::Tensor X, std::string const &win, std::string const &env, std::string const &name, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 
std::string scatter (torch::Tensor X, torch::Tensor Y, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 
std::string scatter (torch::Tensor X, torch::Tensor Y, std::string const &win, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 
std::string scatter (torch::Tensor X, torch::Tensor Y, std::string const &win, std::string const &env, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 
std::string scatter (torch::Tensor X, torch::Tensor Y, std::string const &win, std::string const &env, std::string const &name, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 
std::string line (torch::Tensor Y, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 This function draws a line plot. More...
 
std::string line (torch::Tensor Y, std::string const &win, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 
std::string line (torch::Tensor Y, std::string const &win, std::string const &env, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 
std::string line (torch::Tensor Y, std::string const &win, std::string const &env, std::string const &name, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 
std::string line (torch::Tensor Y, torch::Tensor X, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 
std::string line (torch::Tensor Y, torch::Tensor X, std::string const &win, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 
std::string line (torch::Tensor Y, torch::Tensor X, std::string const &win, std::string const &env, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 
std::string line (torch::Tensor Y, torch::Tensor X, std::string const &win, std::string const &env, std::string const &name, Options const &opts=Options(), UpdateMethod update=UpdateMethod::None)
 

Constructor & Destructor Documentation

visdom::Visdom::Visdom ( ConnectionParams  cparams = ConnectionParams(),
std::string  env = "main",
bool  send = true 
)
visdom::Visdom::~Visdom ( )

Member Function Documentation

std::string visdom::Visdom::close ( std::string const &  win = std::string(),
std::string const &  env = std::string() 
)

This function closes a specific window.

Use win={} to close all windows in an env.

std::string visdom::Visdom::heatmap ( torch::Tensor  tensor,
Options const &  opts = Options() 
)
inline

This function draws a heatmap.

It takes as input an NxM tensor X that specifies the value at each location in the heatmap.

The following opts are supported:

  • opts.colormap: colormap (string; default = "Viridis")
  • opts.xmin: clip minimum value (number, default = X:min())
  • opts.xmax: clip maximum value (number, default = X:max())
  • opts.columnnames: vector of strings containing x-axis labels
  • opts.rownames: vector of strings containing y-axis labels
std::string visdom::Visdom::heatmap ( torch::Tensor  tensor,
std::string const &  win,
Options const &  opts = Options() 
)
inline
std::string visdom::Visdom::heatmap ( torch::Tensor  tensor,
std::string const &  win,
std::string const &  env,
Options const &  opts = Options() 
)
std::string visdom::Visdom::line ( torch::Tensor  Y,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
inline

This function draws a line plot.

It takes in an N or NxM tensor Y that specifies the values of the M lines (that connect N points) to plot. It also takes an optional X tensor that specifies the corresponding x-axis values; X can be an N tensor (in which case all lines will share the same x-axis values) or have the same size as Y.

update can be used to efficiently update the data of an existing line. Use 'append' to append data, 'replace' to use new data. Update data that is all NaN is ignored (can be used for masking update).

The following opts are supported:

  • opts.fillarea : fill area below line (boolean)
  • opts.colormap : colormap (string; default = 'Viridis')
  • opts.markers : show markers (boolean; default = false)
  • opts.markersymbol: marker symbol (string; default = 'dot')
  • opts.markersize : marker size (number; default = '10')
  • opts.legend : table containing legend names

If update is specified, the figure will be updated without creating a new plot – this can be used for efficient updating.

std::string visdom::Visdom::line ( torch::Tensor  Y,
std::string const &  win,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
inline
std::string visdom::Visdom::line ( torch::Tensor  Y,
std::string const &  win,
std::string const &  env,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
inline
std::string visdom::Visdom::line ( torch::Tensor  Y,
std::string const &  win,
std::string const &  env,
std::string const &  name,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
inline
std::string visdom::Visdom::line ( torch::Tensor  Y,
torch::Tensor  X,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
inline
std::string visdom::Visdom::line ( torch::Tensor  Y,
torch::Tensor  X,
std::string const &  win,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
inline
std::string visdom::Visdom::line ( torch::Tensor  Y,
torch::Tensor  X,
std::string const &  win,
std::string const &  env,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
inline
std::string visdom::Visdom::line ( torch::Tensor  Y,
torch::Tensor  X,
std::string const &  win,
std::string const &  env,
std::string const &  name,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
std::string visdom::Visdom::save ( std::vector< std::string > const &  envs)

This funciton allows the user to save envs that are alive on the Tornado server.

The envs can be specified as a list of env ids.

std::string visdom::Visdom::scatter ( torch::Tensor  X,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
inline

This function draws a 2D or 3D scatter plot.

It takes in an Nx2 or Nx3 tensor X that specifies the locations of the N points in the scatter plot. An optional N tensor Y containing discrete labels that range between 1 and K can be specified as well – the labels will be reflected in the colors of the markers.

update can be used to efficiently update the data of an existing line. Use 'append' to append data, 'replace' to use new data. Update data that is all NaN is ignored (can be used for masking update).

The following opts are supported:

  • opts.colormap : colormap (string; default = 'Viridis')
  • opts.markersymbol: marker symbol (string; default = 'dot')
  • opts.markersize : marker size (number; default = '10')
  • opts.markercolor : marker color (np.array; default = None)
  • opts.legend : table containing legend names
std::string visdom::Visdom::scatter ( torch::Tensor  X,
std::string const &  win,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
inline
std::string visdom::Visdom::scatter ( torch::Tensor  X,
std::string const &  win,
std::string const &  env,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
inline
std::string visdom::Visdom::scatter ( torch::Tensor  X,
std::string const &  win,
std::string const &  env,
std::string const &  name,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
inline
std::string visdom::Visdom::scatter ( torch::Tensor  X,
torch::Tensor  Y,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
inline
std::string visdom::Visdom::scatter ( torch::Tensor  X,
torch::Tensor  Y,
std::string const &  win,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
inline
std::string visdom::Visdom::scatter ( torch::Tensor  X,
torch::Tensor  Y,
std::string const &  win,
std::string const &  env,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
inline
std::string visdom::Visdom::scatter ( torch::Tensor  X,
torch::Tensor  Y,
std::string const &  win,
std::string const &  env,
std::string const &  name,
Options const &  opts = Options(),
UpdateMethod  update = UpdateMethod::None 
)
std::string visdom::Visdom::text ( std::string const &  txt,
Options const &  opts = Options() 
)
inline

This funciton prints text in a box.

It takes as input an text string. No specific opts are currently supported.

std::string visdom::Visdom::text ( std::string const &  txt,
std::string const &  win,
Options const &  opts = Options() 
)
inline
std::string visdom::Visdom::text ( std::string const &  txt,
std::string const &  win,
std::string const &  env,
Options const &  opts = Options() 
)

The documentation for this class was generated from the following files: