[**中文**](./README_CN.md)
## Introduction VisualDL, a visualization analysis tool of PaddlePaddle, provides a variety of charts to show the trends of parameters, and visualizes model structures, data samples, histograms of tensors, pr curves and high-dimensional data distributions. It enables users to understand the training process and the model structure more clearly and intuitively so as to optimize models efficiently. VisualDL provides various visualization functions, including tracking metrics in real-time, visualizing the model structure, displaying the data sample, presenting the changes of distributions of tensors, showing the pr curves, projecting high-dimensional data to a lower dimensional space and more. Additionally, VisualDL provides VDL.service, which enables developers easily to save, track and share visualization results of experiments. For specific guidelines of each function, please refer to [**VisualDL User Guide**](./docs/components/UserGuide-en.md). Currently, VisualDL iterates rapidly and new functions will be continuously added. Browsers supported by VisualDL are: - Google Chrome ≥ 79 - Firefox ≥ 67 - Microsoft Edge ≥ 79 - Safari ≥ 11.1 VisualDL natively supports the use of Python. Developers can retrieve plentiful visualization results by simply adding a few lines of Python code into the model before training. ## Contents * [Key Highlights](#Key-Highlights) * [Installation](#Installation) * [Usage Guideline](#Usage-Guideline) * [Function Preview](#Function-Preview) * [Contribution](#Contribution) * [More Details](#More-Details) * [Technical Communication](#Technical-Communication) ## Key Highlights ### Easy to Use The high-level design of API makes it easy to use. Only one click can initiate the visualization of model structures. ### Various Functions The function contains the visualization of training parameters, data samples, graph structures, histograms of tensors, PR curves and high-dimensional data. ### High Compatibility VisualDL provides the visualization of the mainstream model structures such as Paddle, ONNX, Caffe, widely supporting visual analysis for diverse users. ### Fully Support By Integrating into PaddlePaddle and related modules, VisualDL allows developers to use different components unobstructed, and thus have the best experience in the PaddlePaddle ecosystem. ## Installation ### Install by PiP ```shell python -m pip install visualdl -i https://mirror.baidu.com/pypi/simple ``` ### Install by Code ``` git clone https://github.com/PaddlePaddle/VisualDL.git cd VisualDL python setup.py bdist_wheel pip install --upgrade dist/visualdl-*.whl ``` Please note that Python 2 is no longer maintained officially since January 1, 2020. VisualDL now only supports Python 3 in order to ensure the usability of codes. ## Usage Guideline VisualDL stores the data, parameters and other information of the training process in a log file. Users can launch the panel to observe the visualization results. ### 1. Log The Python SDK is provided at the back end of VisualDL, and a logger can be customized through LogWriter. The interface description is shown as follows: ```python class LogWriter(logdir=None, comment='', max_queue=10, flush_secs=120, filename_suffix='', write_to_disk=True, **kwargs) ``` #### Interface Parameters | parameters | type | meaning | | --------------- | ------- | ------------------------------------------------------------ | | logdir | string | The path location of log file. VisualDL will create a log file under this path to record information generated by the training process. If not specified, the path will be `runs/${CURRENT_TIME}`as default. | | comment | string | Add a suffix to the log folder name, which is invalid if logdir is already specified. | | max_queue | int | The maximum capacity of the data generated before recording in a log file. If the capacity is reached, the data is immediately written into the log file. | | flush_secs | int | The maximum cache time of the data generated before recording in a log file, when this time is reached, the data is immediately written to the log file. | | filename_suffix | string | Add a suffix to the default log file name. | | write_to_disk | boolean | Write into disk or not. | | display_name | string | Set the name of different runs when `logdir` is too long or needed to be hidden. If not set, the default name is `logdir`. | | file_name | string | Set the name of the log file. If the file_name already exists, setting the file_name means to continue to add new records in the same log file. Note that the name should include 'vdlrecords'.|
#### Example Create a log file and record scalar values: ```python from visualdl import LogWriter # create a log file under `./log/scalar_test/train` with LogWriter(logdir="./log/scalar_test/train") as writer: # use `add_scalar` to record scalar values writer.add_scalar(tag="acc", step=1, value=0.5678) writer.add_scalar(tag="acc", step=2, value=0.6878) writer.add_scalar(tag="acc", step=3, value=0.9878) ``` ### 2. Launch Panel In the above example, the log has recorded three sets of scalar values. Developers can view the visualization results of the log file through launching the visualDL panel. There are two ways to launch a log file: #### Launch by Command Line Use the command line to launch the VisualDL panel: ```python visualdl --logdir
### 3. Read data in log files using LogReader VisualDL also provides `LogReader` interface to read raw data from log files. ```python class LogReader(file_path='') ``` #### interface parameters | parameters | type | meaning | | ---------- | ------ | ------------------------------------ | | file_path | string | File path of the log file. Required. | #### Example If there is a log file named `vdlrecords.1605533348.log` in the directory of `./log`, we can retrieve the data under the 'loss' tag in the scalar by: ```python from visualdl import LogReader reader = LogReader(file_path='./vdlrecords.1605533348.log') data = reader.get_data('scalar', 'loss') print(data) ``` The result will be a list shown as below: ```python ... id: 5 tag: "Metrics/Training(Step): loss" timestamp: 1605533356039 value: 3.1297709941864014 ... ``` For more information of `LogReader`, please refer to [LogReader](./docs/io/LogReader.md). ## Function Preview ### Scalar **Scalar** makes use of various charts to display how the parameters, such as accuracy, loss and learning rate, change during the training process. In this case, developers can observe not only the single but also the multiple groups of parameters in order to understand the training process and thus speed up the process of model tuning. #### Dynamic Display After the launch of VisualDL Board, the LogReader will continuously record the data to display in the front-end. Hence, the changes of parameters can be visualized in real-time, as shown below:
#### Comparison of Multiple Experiments Developers can compare with multiple experiments by specifying and uploading the path of each experiment at the same time so as to visualize the same parameters in the same chart.
### Image **Image** provides real-time visualizations of the image data during the training process, allowing developers to observe the changes of images in different training stages and to deeply understand the effects of the training process.
### Audio **Audio** aims to allow developers to listen to the audio data in real-time during the training process, helping developers to monitor the process of speech recognition and text-to-speech.
### Graph **Graph** enables developers to visualize model structures by only one click. Moreover, **Graph** allows Developers to explore model attributes, node information, node input and output. aiding them analyze model structure quickly and understand the direction of data flow easily.
### Histogram 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. - Offset Mode
- Overlay Mode
### High Dimensional **High Dimensional** provides three approaches--T-SNE, PCA and UMAP--to do the dimensionality reduction, allowing developers to have an in-depth analysis of the relationship between high-dimensional data and to optimize algorithms based on the analysis.
### VDL.service **VDL.service** enables developers to easily save, track and share visualization results with anyone for free.
## Contribution VisualDL, in which Graph is powered by [Netron](https://github.com/lutzroeder/netron), is an open source project supported by [PaddlePaddle](https://www.paddlepaddle.org/) and [ECharts](https://echarts.apache.org/). Developers are warmly welcomed to use, comment and contribute. ## More Details For more details related to the use of VisualDL, please refer to [**VisualDL User Guide**](./docs/components/UserGuide-en.md)。 ## Technical Communication Welcome to join the official QQ group 104578336 to communicate with PaddlePaddle team and other developers.