VisualDL is a visualization tool designed for Deep Learning. VisualDL provides a variety of charts to show the trends of parameters. It enables users to understand the training process and model structures of Deep Learning models more clearly and intuitively so as to optimize models efficiently.
Currently, VisualDL provides three components: scalar, image, high dimensional. VisualDL iterates rapidly and new functions will be continuously added.
| [ Scalar](#Scalar--Line-Chart) | line chart | Display scalar data such as loss and accuracy dynamically. |
| [Image](#Image--Image-Visualization) | image visualization | Display images, visualizing the input and the output and making it easy to view the changes in the intermediate process. |
| [Graph](#Graph--Network-Structure) | network structure | Visualize network structures, node attributes and data flow, assisting developers to learn and to optimize network structures. |
| [Histogram](#Histogram--Distribution-of-Tensors) | distribution of tensors | Present the changes of distributions of tensors, such as weights/gradients/bias, during the training process. |
| [High Dimensional](#High-Dimensional--Data-Dimensionality-Reduction)| data dimensionality reduction | Project high-dimensional data into 2D/3D space for embedding visualization, making it convenient to observe the correlation between data. |
## Scalar--Line Chart
### Introduction
The data type of the input is scalar values. Scalar is used to present the training parameters in the form of a line chart. By using Scalar to record loss and accuracy, developers are able to track the trend of changes easily through line charts.
### Record Interface
The interface of the Scalar is shown as follows:
```python
add_scalar(tag,value,step,walltime=None)
```
The interface parameters are described as follows:
| tag | string | Record the name of the scalar data,e.g.train/loss. Notice that the name cannot contain `%` |
| value | float | Record the data |
| step | int | Record the training steps |
| walltime | int | Record the time-stamp of the data, the default is the current time-stamp |
*Note that the rules of specifying tags (e.g.train/acc) are:
1. The tag before the first `/` is the parent tag and serves as the tag of the same raw
2. The tag after the first `/` is a child tag, the charts with child tag will be displayed under the parent tag
3. Users can use multiple `/`, but the tag of a raw is the parent tag--the tag before the first `/`
Here are three examples:
- When 'train' is created as the parent tag and 'acc' and 'loss' are created as child tags:`train/acc`、 `train/loss`,the tag of a raw is 'train' , which includes two sub charts--'acc' and 'loss':
- When 'train' is created as the parent tag, and 'test/acc' and 'test/loss' are created as child tags:`train/test/acc`、 `train/test/loss`, the tag of a raw is 'train', which includes two sub charts--'test/acc' and 'test/loss':
- Advanced Usage--Comparison of Multiple Experiments
The following shows the comparison of multiple sets of experiments using Scalar.
There are two steps to achieve this function:
1. Create sub-log files to store the parameter data of each group of experiments
2. When recording data to the scalar component,developers can compare **the same type of parameters for different experiments** by **using the same tag**
```python
fromvisualdlimportLogWriter
if__name__=='__main__':
value=[i/1000.0foriinrange(1000)]
# Step 1: Create a parent folder: log and a child folder: scalar_test
*For more specific details of how to compare multiple experiments, pleas refer to the project on AI Studio:[VisualDL 2.0--Visualization of eye disease recognition training](https://aistudio.baidu.com/aistudio/projectdetail/502834)
### Functional Instruction
* Developers are allowed to zoom in, restore, transform of the coordinate axis (y-axis logarithmic coordinates), download the line chart.
The Image is used to present the change of image data during training. Developers can view images in different training stages by adding few lines of codes to record images in a log file.
### Record Interface
The interface of the Image is shown as follows:
```python
add_image(tag,img,step,walltime=None)
```
The interface parameters are described as follows:
| tag | string | Record the name of the image data,e.g.train/loss. Notice that the name cannot contain `%` |
| img | numpy.ndarray | Images in ndarray format |
| step | int | Record the training steps |
| walltime | int | Record the time-stamp of the data, the default is the current time-stamp |
### Demo
The following shows an example of using Image to record data, and the script can be found in [Image Demo](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/image_test.py).
Graph can visualize the network structure of the model by one click. It enables developers to view the model attributes, node information, searching node and so on. These functions help developers analyze model structures and understand the directions of data flow quickly.
### Demo
There are two methods to launch this component:
- By the front end:
- If developers only need to use Graph, developers can launch VisualDL (Graph) by executing `visualdl`on the command line.
- If developers need to use Graph and other functions at the same time, they need to specify the log file path (using `./log` as an example):
```shell
visualdl --logdir ./log --port 8080
```
- By the backend:
- Add the parameter `--model` and specify the **model file** path (not the folder path) to launch the panel:
```shell
visualdl --model ./log/model --port 8080
```
After the launch, developers can view the network structure:
Histogram displays how the trend of tensors (weight, bias, gradient, etc.) changes during the training process in the form of histogram. Developers can adjust the model structures accurately by having an in-depth understanding of the effect of each layer.
### Record Interface
The interface of the Histogram is shown as follows:
| tag | string | Record the name of the image data,e.g.train/loss. Notice that the name cannot contain `%` |
| values | numpy.ndarray or list | Data is in ndarray or list format |
| step | int | Record the training steps |
| walltime | int | Record the time-stamp of the data, and the default is the current time-stamp |
| buckets | int | The number of segments to generate the histogram and the default value is 10 |
### Demo
The following shows an example of using Histogram to record data, and the script can be found in [Histogram Demo](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/histogram_test.py)
## High Dimensional--Data Dimensionality Reduction
### Introduction
High Dimensional projects high-dimensional data into a low dimensional space, aiding users to have an in-depth analysis of the relationship between high-dimensional data. Two dimensionality reduction algorithms are supported:
| tag | string | Record the name of the high dimensional data, e.g.`default`. Notice that the name cannot contain `%` |
| labels | numpy.array or list | Labels are represented by one-dimensional array. Each element is string type. |
| hot_vectors | numpy.array or list | Each element can be seen as a feature of the tag corresponding to the label. |
| walltime | int | Record the time stamp of the data, the default is the current time stamp. |
### Demo
The following shows an example of how to use High Dimensional component, and script can be found in [High Dimensional Demo](../../demo/components/high_dimensional_test.py)