未验证 提交 fe2a1063 编写于 作者: 走神的阿圆's avatar 走神的阿圆 提交者: GitHub

Update api docs to add more detailed descriptions.

上级 de2ec2ea
...@@ -99,11 +99,9 @@ The Python SDK is provided at the back end of VisualDL, and a logger can be cust ...@@ -99,11 +99,9 @@ The Python SDK is provided at the back end of VisualDL, and a logger can be cust
```python ```python
class LogWriter(logdir=None, class LogWriter(logdir=None,
comment='',
max_queue=10, max_queue=10,
flush_secs=120, flush_secs=120,
filename_suffix='', filename_suffix='',
write_to_disk=True,
**kwargs) **kwargs)
``` ```
...@@ -112,14 +110,11 @@ class LogWriter(logdir=None, ...@@ -112,14 +110,11 @@ class LogWriter(logdir=None,
| parameters | type | meaning | | 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. | | 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. Default value is 10. If the capacity is reached, the data are immediately written into the log file. |
| max_queue | int | The maximum capacity of the data generated before recording in a log file. If the capacity is reached, the data are immediately written into the log file. | | flush_secs | int | The maximum cache time of the data generated before recording in a log file. Default value is 120. When this time is reached, the data are immediately written to the log file. (When the log message queue reaches the maximum cache time or maximum capacity, it will be written to the log file immediately)|
| flush_secs | int | The maximum cache time of the data generated before recording in a log file, when this time is reached, the data are immediately written to the log file. |
| filename_suffix | string | Add a suffix to the default log file name. | | filename_suffix | string | Add a suffix to the default log file name. |
| write_to_disk | boolean | Write into disk or not. | | display_name | string | This parameter is displayed in the location of `Select Data Stream` in the panel. If not set, the default name is `logdir`.(When `logdir` is too long or needed to be hidden). |
| display_name | string | Give a new name to `logdir` 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 will be new records in the same log file, which will continue to be used. Note that the name should include 'vdlrecords'. | | file_name | string | Set the name of the log file. If the file_name already exists, setting the file_name will be new records in the same log file, which will continue to be used. Note that the name should include 'vdlrecords'. |
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103187556-b9714280-48ff-11eb-9052-008e02a21199.png" width="100%"/> <img src="https://user-images.githubusercontent.com/48054808/103187556-b9714280-48ff-11eb-9052-008e02a21199.png" width="100%"/>
</p> </p>
...@@ -160,9 +155,9 @@ Parameter details: ...@@ -160,9 +155,9 @@ Parameter details:
| parameters | meaning | | parameters | meaning |
| --------------- | ------------------------------------------------------------ | | --------------- | ------------------------------------------------------------ |
| --logdir | Set one or more directories of the log. VisualDL will search the log file recursively under this path to display all the experimental results. | | --logdir | Set one or more directories of the log. All the logs in the paths or subdirectories will be displayed on the VisualDL Board indepentently. |
| --model | Set a path to the model file (not a directory). VisualDL will visualize the model file in Graph page. PaddlePaddle、ONNX、Keras、Core ML、Caffe and other model formats are supported. Please refer to [Graph - Functional Instructions](./docs/components/UserGuide-en.md#functional-instructions-2). | | --model | Set a path to the model file (not a directory). VisualDL will visualize the model file in Graph page. PaddlePaddle、ONNX、Keras、Core ML、Caffe and other model formats are supported. Please refer to [Graph - Functional Instructions](./docs/components/UserGuide-en.md#functional-instructions-2). |
| --host | Specify IP address. The default value is `127.0.0.1`. | | --host | Specify IP address. The default value is `127.0.0.1`. Specify it as `0.0.0.0` or public IP address so that other machines can visit VisualDL Board. |
| --port | Set the port. The default value is `8040`. | | --port | Set the port. The default value is `8040`. |
| --cache-timeout | Cache time of the backend. During the cache time, the front end requests the same URL multiple times, and then the returned data are obtained from the cache. The default cache time is 20 seconds. | | --cache-timeout | Cache time of the backend. During the cache time, the front end requests the same URL multiple times, and then the returned data are obtained from the cache. The default cache time is 20 seconds. |
| --language | The language of the VisualDL panel. Language can be specified as 'en' or 'zh', and the default is the language used by the browser. | | --language | The language of the VisualDL panel. Language can be specified as 'en' or 'zh', and the default is the language used by the browser. |
...@@ -198,9 +193,9 @@ The interface parameters are as follows: ...@@ -198,9 +193,9 @@ The interface parameters are as follows:
| parameters | type | meaning | | parameters | type | meaning |
| ------------- | -------------------------------------------------- | ------------------------------------------------------------ | | ------------- | -------------------------------------------------- | ------------------------------------------------------------ |
| logdir | string or list[string_1, string_2, ... , string_n] | Set one or more directories of the log. VisualDL will search the log file recursively under this path to display all the experimental results. | | logdir | string or list[string_1, string_2, ... , string_n] | Set one or more directories of the log. All the logs in the paths or subdirectories will be displayed on the VisualDL Board indepentently.|
| model | string | Set a path to the model file (not a directory). VisualDL will visualize the model file in Graph page. | | model | string | Set a path to the model file (not a directory). VisualDL will visualize the model file in Graph page. |
| host | string | Specify IP address. The default value is `127.0.0.1`. | | host | string | Specify IP address. The default value is `127.0.0.1`. Specify it as `0.0.0.0` or public IP address so that other machines can visit VisualDL Board. |
| port | int | Set the port. The default value is `8040`. | | port | int | Set the port. The default value is `8040`. |
| cache_timeout | int | Cache time of the backend. During the cache time, the front end requests the same URL multiple times, and then the returned data are obtained from the cache. The default cache time is 20 seconds. | | cache_timeout | int | Cache time of the backend. During the cache time, the front end requests the same URL multiple times, and then the returned data are obtained from the cache. The default cache time is 20 seconds. |
| language | string | The language of the VisualDL panel. Language can be specified as 'en' or 'zh', and the default is the language used by the browser. | | language | string | The language of the VisualDL panel. Language can be specified as 'en' or 'zh', and the default is the language used by the browser. |
......
...@@ -101,11 +101,9 @@ VisualDL的后端提供了Python SDK,可通过LogWriter定制一个日志记 ...@@ -101,11 +101,9 @@ VisualDL的后端提供了Python SDK,可通过LogWriter定制一个日志记
```python ```python
class LogWriter(logdir=None, class LogWriter(logdir=None,
comment='',
max_queue=10, max_queue=10,
flush_secs=120, flush_secs=120,
filename_suffix='', filename_suffix='',
write_to_disk=True,
display_name='', display_name='',
file_name='', file_name='',
**kwargs) **kwargs)
...@@ -116,13 +114,11 @@ class LogWriter(logdir=None, ...@@ -116,13 +114,11 @@ class LogWriter(logdir=None,
| 参数 | 格式 | 含义 | | 参数 | 格式 | 含义 |
| --------------- | ------- | ------------------------------------------------------------ | | --------------- | ------- | ------------------------------------------------------------ |
| logdir | string | 日志文件所在的路径,VisualDL将在此路径下建立日志文件并进行记录,如果不填则默认为`runs/${CURRENT_TIME}` | | logdir | string | 日志文件所在的路径,VisualDL将在此路径下建立日志文件并进行记录,如果不填则默认为`runs/${CURRENT_TIME}` |
| comment | string | 为日志文件夹名添加后缀,如果制定了logdir则此项无效 |
| max_queue | int | 日志记录消息队列的最大容量,达到此容量则立即写入到日志文件 | | max_queue | int | 日志记录消息队列的最大容量,达到此容量则立即写入到日志文件 |
| flush_secs | int | 日志记录消息队列的最大缓存时间,达到此时间则立即写入到日志文件 | | flush_secs | int | 日志记录消息队列的最大缓存时间,达到此时间则立即写入到日志文件(日志消息队列到达最大缓存时间或最大容量,都会立即写入日志文件) |
| filename_suffix | string | 为默认的日志文件名添加后缀 | | filename_suffix | string | 为默认的日志文件名添加后缀 |
| write_to_disk | boolean | 是否写入到磁盘 | | display_name | string | 指定面板启动后显示的路径,如不指定此项则显示日志所在的实际路径,当日志所在路径过长或想隐藏日志所在路径时可指定此参数 |
| display_name | string | 在面板中替换实际显示的`logdir`,当日志所在路径过长或想隐藏日志所在路径时可指定此参数 | | file_name | string | 指定写入的日志文件名,如果指定的文件名已经存在,则将日志续写在此文件中,因此可通过此参数实现日志续写的功能,文件名必须包括`vdlrecords` |
| file_name | string | 指定写入的日志文件名,如果指定的文件名已经存在,则将日志续写在此文件中,文件名必须包括`vdlrecords` |
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103187556-b9714280-48ff-11eb-9052-008e02a21199.png" width="100%"/> <img src="https://user-images.githubusercontent.com/48054808/103187556-b9714280-48ff-11eb-9052-008e02a21199.png" width="100%"/>
...@@ -165,7 +161,7 @@ visualdl --logdir <dir_1, dir_2, ... , dir_n> --model <model_file> --host <host> ...@@ -165,7 +161,7 @@ visualdl --logdir <dir_1, dir_2, ... , dir_n> --model <model_file> --host <host>
| --------------- | ------------------------------------------------------------ | | --------------- | ------------------------------------------------------------ |
| --logdir | 设定日志所在目录,可以指定多个目录,VisualDL将遍历并且迭代寻找指定目录的子目录,将所有实验结果进行可视化 | | --logdir | 设定日志所在目录,可以指定多个目录,VisualDL将遍历并且迭代寻找指定目录的子目录,将所有实验结果进行可视化 |
| --model | 设定模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化,目前可支持PaddlePaddle、ONNX、Keras、Core ML、Caffe等多种模型结构,详情可查看[graph支持模型种类](./docs/components/README.md#%E5%8A%9F%E8%83%BD%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E-2) | | --model | 设定模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化,目前可支持PaddlePaddle、ONNX、Keras、Core ML、Caffe等多种模型结构,详情可查看[graph支持模型种类](./docs/components/README.md#%E5%8A%9F%E8%83%BD%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E-2) |
| --host | 设定IP,默认为`127.0.0.1` | | --host | 设定IP,默认为`127.0.0.1`,若想使得本机以外的机器访问启动的VisualDL面板,需指定此项为`0.0.0.0`或自己的公网IP地址 |
| --port | 设定端口,默认为`8040` | | --port | 设定端口,默认为`8040` |
| --cache-timeout | 后端缓存时间,在缓存时间内前端多次请求同一url,返回的数据从缓存中获取,默认为20秒 | | --cache-timeout | 后端缓存时间,在缓存时间内前端多次请求同一url,返回的数据从缓存中获取,默认为20秒 |
| --language | VisualDL面板语言,可指定为'en'或'zh',默认为浏览器使用语言 | | --language | VisualDL面板语言,可指定为'en'或'zh',默认为浏览器使用语言 |
...@@ -200,9 +196,9 @@ visualdl.server.app.run(logdir, ...@@ -200,9 +196,9 @@ visualdl.server.app.run(logdir,
| 参数 | 格式 | 含义 | | 参数 | 格式 | 含义 |
| ------------- | ------------------------------------------------ | ------------------------------------------------------------ | | ------------- | ------------------------------------------------ | ------------------------------------------------------------ |
| logdir | string或list[string_1, string_2, ... , string_n] | 日志文件所在的路径,VisualDL将在此路径下递归搜索日志文件并进行可视化,可指定单个或多个路径 | | logdir | string或list[string_1, string_2, ... , string_n] | 日志文件所在的路径,VisualDL将在此路径下递归搜索日志文件并进行可视化,可指定单个或多个路径,每个路径中及其子目录中的日志都将视为独立日志展现在前端面板上 |
| model | string | 模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化 | | model | string | 模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化,目前可支持PaddlePaddle、ONNX、Keras、Core ML、Caffe等多种模型结构,详情可查看[graph支持模型种类](./docs/components/README.md#%E5%8A%9F%E8%83%BD%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E-2) |
| host | string | 指定启动服务的ip,默认为`127.0.0.1` | | host | string | 设定IP,默认为`127.0.0.1`,若想使得本机以外的机器访问启动的VisualDL面板,需指定此项为`0.0.0.0`或自己的公网IP地址 |
| port | int | 启动服务端口,默认为`8040` | | port | int | 启动服务端口,默认为`8040` |
| cache_timeout | int | 后端缓存时间,在缓存时间内前端多次请求同一url,返回的数据从缓存中获取,默认为20秒 | | cache_timeout | int | 后端缓存时间,在缓存时间内前端多次请求同一url,返回的数据从缓存中获取,默认为20秒 |
| language | string | VisualDL面板语言,可指定为'en'或'zh',默认为浏览器使用语言 | | language | string | VisualDL面板语言,可指定为'en'或'zh',默认为浏览器使用语言 |
......
[**中文**](./README.md)
<p align="center">
<img src="https://raw.githubusercontent.com/PaddlePaddle/VisualDL/develop/frontend/packages/core/public/images/logo-visualdl.svg?sanitize=true" width="70%"/>
</p>
<p align="center">
<a href="https://travis-ci.org/PaddlePaddle/VisualDL"><img src="https://img.shields.io/travis/paddlepaddle/visualdl/develop?style=flat-square" alt="Build Status" /></a>
<a href="https://pypi.org/project/visualdl/"><img src="https://img.shields.io/pypi/v/visualdl?style=flat-square" alt="PyPI" /></a>
<a href="https://pypi.org/project/visualdl/#files"><img src="https://img.shields.io/pypi/dm/visualdl?style=flat-square" alt="Downloads" /></a>
<a href="https://github.com/PaddlePaddle/VisualDL/blob/develop/LICENSE"><img src="https://img.shields.io/github/license/paddlepaddle/visualdl?style=flat-square" alt="License" /></a>
</p>
<p align="center">
<a href="javascript:void(0)"><img src="https://img.shields.io/badge/QQ_Group-1045783368-52B6EF?style=social&logo=tencent-qq&logoColor=000&logoWidth=20" alt="QQ Group" /></a>
</p>
## 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 continously added.
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`.|
#### 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. Develpers 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 <dir_1, dir_2, ... , dir_n> --host <host> --port <port> --cache-timeout <cache_timeout> --language <language> --public-path <public_path> --api-only
```
Parameter details:
| parameters | meaning |
| --------------- | ------------------------------------------------------------ |
| --logdir | Set one or more directories of the log. VisualDL will search the log file recursively under this path to display the all experimental results. |
| --host | Specify IP address. The default value is·`127.0.0.1`. |
| --port | Set the port. The default value is`8040`. |
| --cache-timeout | Cache time of the backend. During the cache time, the front end requests the same URL multiple times, and then the returned data is obtained from the cache. The default cache time is 20 seconds. |
| --language | The language of the VisualDL panel. Language can be specified as 'en' or 'zh', and the default is the language used by the browser. |
| --public-path | The URL path of the VisualDL panel. The default path is '/app', meaning that the access address is 'http://&lt;host&gt;:&lt;port&gt;/app'. |
| --api-only | Decide whether or not to provide only API. If this parameter is set, VisualDL will only provides API service without displaying the web page, and the API address is 'http://&lt;host&gt;:&lt;port&gt;/&lt;public_path&gt;/api'. Additionally, If the public_path parameter is not specified, the default address is 'http://&lt;host&gt;:&lt;port&gt;/api'. |
To visualize the log file generated in the previous step, developers can launch the panel through the command:
```
visualdl --logdir ./log
```
#### Launch in Python Script
Developers can start the VisualDL panel in Python script as follows:
```python
visualdl.server.app.run(logdir,
host="127.0.0.1",
port=8080,
cache_timeout=20,
language=None,
public_path=None,
api_only=False,
open_browser=False)
```
Please note: since all parameters are indefinite except `logdir`, developers should specify parameter names when using them.
The interface parameters are as follows:
| parameters | type | meaning |
| ------------- | -------------------------------------------------- | ------------------------------------------------------------ |
| logdir | string or list[string_1, string_2, ... , string_n] | Set one or more directories of the log. VisualDL will search the log file recursively under this path to display the all experimental results. |
| host | string | Specify IP address. The default value is·`127.0.0.1`. |
| port | int | Set the port. The default value is`8040`. |
| cache_timeout | int | Cache time of the backend. During the cache time, the front end requests the same URL multiple times, and then the returned data is obtained from the cache. The default cache time is 20 seconds. |
| language | string | The language of the VisualDL panel. Language can be specified as 'en' or 'zh', and the default is the language used by the browser. |
| public_path | string | The URL path of the VisualDL panel. The default path is '/app', meaning that the access address is 'http://&lt;host&gt;:&lt;port&gt;/app'. |
| api_only | boolean | Decide whether or not to provide only API. If this parameter is set, VisualDL will only provides API service without displaying the web page, and the API address is 'http://&lt;host&gt;:&lt;port&gt;/&lt;public_path&gt;/api'. Additionally, If the parameter public_path is not specified, the default address is 'http://&lt;host&gt;:&lt;port&gt;/api'. |
| open_browser | boolean | Whether or not to open the browser. If this parameter is set as True, the browser will be openned automatically and VisualDL panel will be launched at the same time. If parameter api_only is specified as True, parameter open_browser can be ignored. |
To visualize the log file generated in the previous step, developers can launch the panel through the command:
```python
from visualdl.server import app
app.run(logdir="./log")
```
After launching the panel by one of the above methods, developers can see the visualization results on the browser shown as blow:
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90868674-ba321f00-e3c9-11ea-83c1-f03c6dd19187.png" width="70%"/>
</p>
## 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 launchment 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:
<p align="center">
<img src="https://visualdl.bj.bcebos.com/images/dynamic_display.gif" width="60%"/>
</p>
#### 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.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90869567-fdd95880-e3ca-11ea-9855-6c97ad5c8ae7.gif" width="100%"/>
</p>
### 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.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90869677-22353500-e3cb-11ea-9830-2334bdd8e52e.gif" width="60%"/>
</p>
### 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.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90869771-47c23e80-e3cb-11ea-8b2a-a38b6c33d64b.png" width="85%"/>
</p>
### 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.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90869866-6aecee00-e3cb-11ea-8211-b8af070239e6.png" width="85%"/>
</p>
### 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
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90870121-bd2e0f00-e3cb-11ea-89cf-6622cb607b89.png" width="85%"/>
</p>
- Overlay Mode
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90870194-cfa84880-e3cb-11ea-8a66-bebcad267a10.png" width="85%"/>
</p>
### High Dimensional
**High Dimensional** provides two approaches--T-SNE and PCA--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.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90870677-85739700-e3cc-11ea-8653-18fa5c4106a3.GIF" width="85%"/>
</p>
### VDL.service
**VDL.service** enables developers to easily save, track and share visualization results with anyone for free.
<p align="center">
<img src=https://user-images.githubusercontent.com/48054808/93731055-fbeafb00-fbfd-11ea-80f4-bbfd08a0fc35.png
</p>
## 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/README.md)
## Technical Communication
Welcome to join the official QQ group 104578336 to communicate with PaddlePaddle team and other developers.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/82522691-c2758680-9b5c-11ea-9aee-fca994aba175.png" width="20%"/>
</p>
[**English**](./README-en.md) [**中文**](./README_CN.md)
<p align="center"> <p align="center">
<img src="https://raw.githubusercontent.com/PaddlePaddle/VisualDL/develop/frontend/packages/core/public/images/logo-visualdl.svg?sanitize=true" width="70%"/> <img src="https://raw.githubusercontent.com/PaddlePaddle/VisualDL/develop/frontend/packages/core/public/images/logo-visualdl.svg?sanitize=true" width="70%"/>
...@@ -14,62 +13,54 @@ ...@@ -14,62 +13,54 @@
</p> </p>
<p align="center"> <p align="center">
<a href="https://jq.qq.com/?_wv=1027&k=TyzyVT4C" target="_blank" rel="noreferrer"><img src="https://img.shields.io/badge/QQ_Group-1045783368-52B6EF?style=social&logo=tencent-qq&logoColor=000&logoWidth=20" alt="QQ Group" /></a> <a href="javascript:void(0)"><img src="https://img.shields.io/badge/QQ_Group-1045783368-52B6EF?style=social&logo=tencent-qq&logoColor=000&logoWidth=20" alt="QQ Group" /></a>
</p> </p>
## 介绍 ## Introduction
VisualDL是飞桨可视化分析工具,以丰富的图表呈现训练参数变化趋势、模型结构、数据样本、高维数据分布等。可帮助用户更清晰直观地理解深度学习模型训练过程及模型结构,进而实现高效的模型优化。 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提供丰富的可视化功能,支持标量、图结构、数据样本可视化、直方图、PR曲线及高维数据降维呈现等诸多功能,同时VisualDL提供可视化结果保存服务,通过VDL.service生成链接,保存并分享可视化结果。具体功能使用方式,请参见 [**VisualDL使用指南**](./components/README.md)。项目正处于高速迭代中,敬请期待新组件的加入。
VisualDL支持浏览器种类:Chrome(81和83)、Safari 13、FireFox(77和78)、Edge(Chromium版)。
VisualDL原生支持python的使用, 通过在模型的Python配置中添加几行代码,便可为训练过程提供丰富的可视化支持。
## 目录
* [核心亮点](#核心亮点)
* [安装方式](#安装方式)
* [使用方式](#使用方式)
* [可视化功能概览](#可视化功能概览)
* [开源贡献](#开源贡献) 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 continously added.
* [更多细节](#更多细节) 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)
## 核心亮点
### 简单易用
API设计简洁易懂,使用简单。模型结构一键实现可视化。 ## Key Highlights
### 功能丰富 ### Easy to Use
功能覆盖标量、数据样本、图结构、直方图、PR曲线及数据降维可视化。 The high-level design of API makes it easy to use. Only one click can initiate the visualization of model structures.
### 高兼容性 ### Various Functions
全面支持Paddle、ONNX、Caffe等市面主流模型结构可视化,广泛支持各类用户进行可视化分析。 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
### 使用pip安装 ### Install by PiP
```shell ```shell
python -m pip install visualdl -i https://mirror.baidu.com/pypi/simple python -m pip install visualdl -i https://mirror.baidu.com/pypi/simple
``` ```
### 使用代码安装 ### Install by Code
``` ```
git clone https://github.com/PaddlePaddle/VisualDL.git git clone https://github.com/PaddlePaddle/VisualDL.git
...@@ -78,15 +69,15 @@ cd VisualDL ...@@ -78,15 +69,15 @@ cd VisualDL
python setup.py bdist_wheel python setup.py bdist_wheel
pip install --upgrade dist/visualdl-*.whl pip install --upgrade dist/visualdl-*.whl
``` ```
需要注意,官方自2020年1月1日起不再维护Python2,为了保障代码可用性,VisualDL现仅支持Python3 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将训练过程中的数据、参数等信息储存至日志文件中后,启动面板即可查看可视化结果。 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. 记录日志 ### 1. Log
VisualDL的后端提供了Python SDK,可通过LogWriter定制一个日志记录器,接口如下: 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 ```python
class LogWriter(logdir=None, class LogWriter(logdir=None,
...@@ -95,71 +86,70 @@ class LogWriter(logdir=None, ...@@ -95,71 +86,70 @@ class LogWriter(logdir=None,
flush_secs=120, flush_secs=120,
filename_suffix='', filename_suffix='',
write_to_disk=True, write_to_disk=True,
display_name='',
**kwargs) **kwargs)
``` ```
#### 接口参数 #### Interface Parameters
| 参数 | 格式 | 含义 | | parameters | type | meaning |
| --------------- | ------- | ------------------------------------------------------------ | | --------------- | ------- | ------------------------------------------------------------ |
| logdir | string | 日志文件所在的路径,VisualDL将在此路径下建立日志文件并进行记录,如果不填则默认为`runs/${CURRENT_TIME}` | | 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 | 为日志文件夹名添加后缀,如果制定了logdir则此项无效 | | comment | string | Add a suffix to the log folder name, which is invalid if logdir is already specified. |
| max_queue | int | 日志记录消息队列的最大容量,达到此容量则立即写入到日志文件 | | max_queue | int | The maximum capacity of the data generated before recording in a log file. Default value is 10. If the capacity is reached, the data is immediately written into the log file. The cache is not used if set to 0. |
| flush_secs | int | 日志记录消息队列的最大缓存时间,达到此时间则立即写入到日志文件 | | flush_secs | int | The maximum cache time of the data generated before recording in a log file. Default value is 120. When this time is reached, the data is immediately written to the log file. The cache is not used if set to 0. |
| filename_suffix | string | 为默认的日志文件名添加后缀 | | filename_suffix | string | Add a suffix to the default log file name. |
| write_to_disk | boolean | 是否写入到磁盘 | | write_to_disk | boolean | Write into disk or not. |
| display_name | string | 在面板中替换实际显示的`logdir`,当日志所在路径过长或想隐藏日志所在路径时可指定此参数 | | 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`.|
#### 示例
设置日志文件并记录标量数据: #### Example
Create a log file and record scalar values:
```python ```python
from visualdl import LogWriter from visualdl import LogWriter
# 在`./log/scalar_test/train`路径下建立日志文件 # create a log file under `./log/scalar_test/train`
with LogWriter(logdir="./log/scalar_test/train") as writer: with LogWriter(logdir="./log/scalar_test/train") as writer:
# 使用scalar组件记录一个标量数据 # use `add_scalar` to record scalar values
writer.add_scalar(tag="acc", step=1, value=0.5678) 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=2, value=0.6878)
writer.add_scalar(tag="acc", step=3, value=0.9878) writer.add_scalar(tag="acc", step=3, value=0.9878)
``` ```
### 2. 启动面板 ### 2. Launch Panel
在上述示例中,日志已记录三组标量数据,现可启动VisualDL面板查看日志的可视化结果,共有两种启动方式: In the above example, the log has recorded three sets of scalar values. Develpers 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
使用命令行启动VisualDL面板,命令格式如下 Use the command line to launch the VisualDL panel
```python ```python
visualdl --logdir <dir_1, dir_2, ... , dir_n> --host <host> --port <port> --cache-timeout <cache_timeout> --language <language> --public-path <public_path> --api-only visualdl --logdir <dir_1, dir_2, ... , dir_n> --host <host> --port <port> --cache-timeout <cache_timeout> --language <language> --public-path <public_path> --api-only
``` ```
参数详情: Parameter details:
| 参数 | 意义 | | parameters | meaning |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --------------- | ------------------------------------------------------------ |
| --logdir | 设定日志所在目录,可以指定多个目录,VisualDL将遍历并且迭代寻找指定目录的子目录,将所有实验结果进行可视化 | | --logdir | Set one or more directories of the log. VisualDL will search the log file recursively under this path to display the all experimental results. |
| --model | 设定模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化,目前可支持PaddlePaddle、ONNX、Keras、Core ML、Caffe等多种模型结构,详情可查看[graph支持模型种类](./docs/components/README.md#%E5%8A%9F%E8%83%BD%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E-2) | | --host | Specify IP address. The default value is·`127.0.0.1`. |
| --host | 设定IP,默认为`127.0.0.1` | | --port | Set the port. The default value is`8040`. |
| --port | 设定端口,默认为`8040` | | --cache-timeout | Cache time of the backend. During the cache time, the front end requests the same URL multiple times, and then the returned data is obtained from the cache. The default cache time is 20 seconds. |
| --cache-timeout | 后端缓存时间,在缓存时间内前端多次请求同一url,返回的数据从缓存中获取,默认为20秒 | | --language | The language of the VisualDL panel. Language can be specified as 'en' or 'zh', and the default is the language used by the browser. |
| --language | VisualDL面板语言,可指定为'en'或'zh',默认为浏览器使用语言 | | --public-path | The URL path of the VisualDL panel. The default path is '/app', meaning that the access address is 'http://&lt;host&gt;:&lt;port&gt;/app'. |
| --public-path | VisualDL面板URL路径,默认是'/app',即访问地址为'http://&lt;host&gt;:&lt;port&gt;/app' | | --api-only | Decide whether or not to provide only API. If this parameter is set, VisualDL will only provides API service without displaying the web page, and the API address is 'http://&lt;host&gt;:&lt;port&gt;/&lt;public_path&gt;/api'. Additionally, If the public_path parameter is not specified, the default address is 'http://&lt;host&gt;:&lt;port&gt;/api'. |
| --api-only | 是否只提供API,如果设置此参数,则VisualDL不提供页面展示,只提供API服务,此时API地址为'http://&lt;host&gt;:&lt;port&gt;/&lt;public_path&gt;/api';若没有设置public_path参数,则默认为'http://&lt;host&gt;:&lt;port&gt;/api' |
针对上一步生成的日志,启动命令为: To visualize the log file generated in the previous step, developers can launch the panel through the command:
``` ```
visualdl --logdir ./log visualdl --logdir ./log
``` ```
#### 在Python脚本中启动 #### Launch in Python Script
支持在Python脚本中启动VisualDL面板,接口如下: Developers can start the VisualDL panel in Python script as follows:
```python ```python
visualdl.server.app.run(logdir, visualdl.server.app.run(logdir,
...@@ -172,23 +162,22 @@ visualdl.server.app.run(logdir, ...@@ -172,23 +162,22 @@ visualdl.server.app.run(logdir,
open_browser=False) open_browser=False)
``` ```
请注意:除`logdir`外,其他参数均为不定参数,传递时请指明参数名。 Please note: since all parameters are indefinite except `logdir`, developers should specify parameter names when using them.
接口参数具体如下: The interface parameters are as follows:
| 参数 | 格式 | 含义 | | parameters | type | meaning |
| ------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ------------- | -------------------------------------------------- | ------------------------------------------------------------ |
| logdir | string或list[string_1, string_2, ... , string_n] | 日志文件所在的路径,VisualDL将在此路径下递归搜索日志文件并进行可视化,可指定单个或多个路径 | | logdir | string or list[string_1, string_2, ... , string_n] | Set one or more directories of the log. VisualDL will search the log file recursively under this path to display the all experimental results. |
| model | string | 模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化 | | host | string | Specify IP address. The default value is·`127.0.0.1`. |
| host | string | 指定启动服务的ip,默认为`127.0.0.1` | | port | int | Set the port. The default value is`8040`. |
| port | int | 启动服务端口,默认为`8040` | | cache_timeout | int | Cache time of the backend. During the cache time, the front end requests the same URL multiple times, and then the returned data is obtained from the cache. The default cache time is 20 seconds. |
| cache_timeout | int | 后端缓存时间,在缓存时间内前端多次请求同一url,返回的数据从缓存中获取,默认为20秒 | | language | string | The language of the VisualDL panel. Language can be specified as 'en' or 'zh', and the default is the language used by the browser. |
| language | string | VisualDL面板语言,可指定为'en'或'zh',默认为浏览器使用语言 | | public_path | string | The URL path of the VisualDL panel. The default path is '/app', meaning that the access address is 'http://&lt;host&gt;:&lt;port&gt;/app'. |
| public_path | string | VisualDL面板URL路径,默认是'/app',即访问地址为'http://&lt;host&gt;:&lt;port&gt;/app' | | api_only | boolean | Decide whether or not to provide only API. If this parameter is set, VisualDL will only provides API service without displaying the web page, and the API address is 'http://&lt;host&gt;:&lt;port&gt;/&lt;public_path&gt;/api'. Additionally, If the parameter public_path is not specified, the default address is 'http://&lt;host&gt;:&lt;port&gt;/api'. |
| api_only | boolean | 是否只提供API,如果设置此参数,则VisualDL不提供页面展示,只提供API服务,此时API地址为'http://&lt;host&gt;:&lt;port&gt;/&lt;public_path&gt;/api';若没有设置public_path参数,则默认为'http://&lt;host&gt;:&lt;port&gt;/api' | | open_browser | boolean | Whether or not to open the browser. If this parameter is set as True, the browser will be openned automatically and VisualDL panel will be launched at the same time. If parameter api_only is specified as True, parameter open_browser can be ignored. |
| open_browser | boolean | 是否打开浏览器,设置为True则在启动后自动打开浏览器并访问VisualDL面板,若设置api_only,则忽略此参数 |
针对上一步生成的日志,我们的启动脚本为: To visualize the log file generated in the previous step, developers can launch the panel through the command:
```python ```python
from visualdl.server import app from visualdl.server import app
...@@ -196,113 +185,104 @@ from visualdl.server import app ...@@ -196,113 +185,104 @@ from visualdl.server import app
app.run(logdir="./log") app.run(logdir="./log")
``` ```
在使用任意一种方式启动VisualDL面板后,打开浏览器访问VisualDL面板,即可查看日志的可视化结果,如图: After launching the panel by one of the above methods, developers can see the visualization results on the browser shown as blow:
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/82786044-67ae9880-9e96-11ea-8a2b-3a0951a6ec19.png" width="60%"/> <img src="https://user-images.githubusercontent.com/48054808/90868674-ba321f00-e3c9-11ea-83c1-f03c6dd19187.png" width="70%"/>
</p> </p>
## 可视化功能概览 ## Function Preview
### Scalar ### Scalar
以图表形式实时展示训练过程参数,如loss、accuracy。让用户通过观察单组或多组训练参数变化,了解训练过程,加速模型调优。具有两大特点: **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
在启动VisualDL Board后,LogReader将不断增量的读取日志中数据并供前端调用展示,因此能够在训练中同步观测指标变化,如下图: After the launchment 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:
<p align="center"> <p align="center">
<img src="https://visualdl.bj.bcebos.com/images/dynamic_display.gif" width="60%"/> <img src="https://visualdl.bj.bcebos.com/images/dynamic_display.gif" width="60%"/>
</p> </p>
#### 多实验对比 #### Comparison of Multiple Experiments
只需在启动VisualDL Board的时将每个实验日志所在路径同时传入即可,每个实验中相同tag的指标将绘制在一张图中同步呈现,如下图: 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.
<p align="center"> <p align="center">
<img src="https://visualdl.bj.bcebos.com/images/multi_experiments.gif" width="100%"/> <img src="https://user-images.githubusercontent.com/48054808/90869567-fdd95880-e3ca-11ea-9855-6c97ad5c8ae7.gif" width="100%"/>
</p> </p>
### Image ### 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.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90356439-24715980-e082-11ea-8896-01c27fc2fc9b.gif" width="85%"/> <img src="https://user-images.githubusercontent.com/48054808/90869677-22353500-e3cb-11ea-9830-2334bdd8e52e.gif" width="60%"/>
</p> </p>
### Audio ### 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.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/87659138-b4746880-c78f-11ea-965b-c33804e7c296.png" width="85%"/> <img src="https://user-images.githubusercontent.com/48054808/90869771-47c23e80-e3cb-11ea-8b2a-a38b6c33d64b.png" width="85%"/>
</p> </p>
### Graph ### 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.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84483052-5acdd980-accb-11ea-8519-1608da7ee698.png" width="85%"/> <img src="https://user-images.githubusercontent.com/48054808/90869866-6aecee00-e3cb-11ea-8211-b8af070239e6.png" width="85%"/>
</p> </p>
### Histogram ### Histogram
以直方图形式展示Tensor(weight、bias、gradient等)数据在训练过程中的变化趋势。深入了解模型各层效果,帮助开发者精准调整模型结构。 **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模式 - Offset Mode
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86551031-86647c80-bf76-11ea-8ec2-8c86826c8137.png" width="85%"/> <img src="https://user-images.githubusercontent.com/48054808/90870121-bd2e0f00-e3cb-11ea-89cf-6622cb607b89.png" width="85%"/>
</p> </p>
- Overlay模式
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86551033-882e4000-bf76-11ea-8e6a-af954c662ced.png" width="85%"/>
</p>
### PR Curve - Overlay Mode
精度-召回率曲线,帮助开发者权衡模型精度和召回率之间的平衡,设定最佳阈值。
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86738774-ee46c000-c067-11ea-90d2-a98aac445cca.png" width="85%"/> <img src="https://user-images.githubusercontent.com/48054808/90870194-cfa84880-e3cb-11ea-8a66-bebcad267a10.png" width="85%"/>
</p> </p>
### High Dimensional ### High Dimensional
将高维数据进行降维展示,目前支持T-SNE、PCA两种降维方式,用于深入分析高维数据间的关系,方便用户根据数据特征进行算法优化。 **High Dimensional** provides two approaches--T-SNE and PCA--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.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/82396340-3e4dd100-9a80-11ea-911d-798acdbc9c90.gif" width="85%"/> <img src="https://user-images.githubusercontent.com/48054808/90870677-85739700-e3cc-11ea-8653-18fa5c4106a3.GIF" width="85%"/>
</p> </p>
### VDL.service ### VDL.service
VisualDL可视化结果保存服务,以链接形式将可视化结果保存下来,方便用户快速、便捷的进行托管与分享。 **VDL.service** enables developers to easily save, track and share visualization results with anyone for free.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93729521-72382f00-fbf7-11ea-91ff-6b6ab4b41e32.png" width="85%"/> <img src=https://user-images.githubusercontent.com/48054808/93731055-fbeafb00-fbfd-11ea-80f4-bbfd08a0fc35.png
</p> </p>
## Contribution
## 开源贡献
VisualDL 是由 [PaddlePaddle](https://www.paddlepaddle.org/)[ECharts](https://echarts.apache.org/) 合作推出的开源项目。 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.
Graph 相关功能由 [Netron](https://github.com/lutzroeder/netron) 提供技术支持。
欢迎所有人使用,提意见以及贡献代码。
## 更多细节 ## More Details
想了解更多关于VisualDL可视化功能的使用详情介绍,请查看[**VisualDL使用指南**](./docs/components/README.md) For more details related to the use of VisualDL, please refer to [**VisualDL User Guide**](./docs/components/README.md)
## 技术交流 ## Technical Communication
欢迎您加入VisualDL官方QQ群:1045783368 与飞桨团队以及其他用户共同针对VisualDL进行讨论与交流。 Welcome to join the official QQ group 104578336 to communicate with PaddlePaddle team and other developers.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/82522691-c2758680-9b5c-11ea-9aee-fca994aba175.png" width="20%"/> <img src="https://user-images.githubusercontent.com/48054808/82522691-c2758680-9b5c-11ea-9aee-fca994aba175.png" width="20%"/>
......
[**English**](./README.md)
<p align="center">
<img src="https://raw.githubusercontent.com/PaddlePaddle/VisualDL/develop/frontend/packages/core/public/images/logo-visualdl.svg?sanitize=true" width="70%"/>
</p>
<p align="center">
<a href="https://travis-ci.org/PaddlePaddle/VisualDL"><img src="https://img.shields.io/travis/paddlepaddle/visualdl/develop?style=flat-square" alt="Build Status" /></a>
<a href="https://pypi.org/project/visualdl/"><img src="https://img.shields.io/pypi/v/visualdl?style=flat-square" alt="PyPI" /></a>
<a href="https://pypi.org/project/visualdl/#files"><img src="https://img.shields.io/pypi/dm/visualdl?style=flat-square" alt="Downloads" /></a>
<a href="https://github.com/PaddlePaddle/VisualDL/blob/develop/LICENSE"><img src="https://img.shields.io/github/license/paddlepaddle/visualdl?style=flat-square" alt="License" /></a>
</p>
<p align="center">
<a href="https://jq.qq.com/?_wv=1027&k=TyzyVT4C" target="_blank" rel="noreferrer"><img src="https://img.shields.io/badge/QQ_Group-1045783368-52B6EF?style=social&logo=tencent-qq&logoColor=000&logoWidth=20" alt="QQ Group" /></a>
</p>
## 介绍
VisualDL是飞桨可视化分析工具,以丰富的图表呈现训练参数变化趋势、模型结构、数据样本、高维数据分布等。可帮助用户更清晰直观地理解深度学习模型训练过程及模型结构,进而实现高效的模型优化。
VisualDL提供丰富的可视化功能,支持标量、图结构、数据样本可视化、直方图、PR曲线及高维数据降维呈现等诸多功能,同时VisualDL提供可视化结果保存服务,通过VDL.service生成链接,保存并分享可视化结果。具体功能使用方式,请参见 [**VisualDL使用指南**](./components/README.md)。项目正处于高速迭代中,敬请期待新组件的加入。
VisualDL支持浏览器种类:Chrome(81和83)、Safari 13、FireFox(77和78)、Edge(Chromium版)。
VisualDL原生支持python的使用, 通过在模型的Python配置中添加几行代码,便可为训练过程提供丰富的可视化支持。
## 目录
* [核心亮点](#核心亮点)
* [安装方式](#安装方式)
* [使用方式](#使用方式)
* [可视化功能概览](#可视化功能概览)
* [开源贡献](#开源贡献)
* [更多细节](#更多细节)
## 核心亮点
### 简单易用
API设计简洁易懂,使用简单。模型结构一键实现可视化。
### 功能丰富
功能覆盖标量、数据样本、图结构、直方图、PR曲线及数据降维可视化。
### 高兼容性
全面支持Paddle、ONNX、Caffe等市面主流模型结构可视化,广泛支持各类用户进行可视化分析。
### 全面支持
与飞桨服务平台及工具组件全面打通,为您在飞桨生态系统中提供最佳使用体验。
## 安装方式
### 使用pip安装
```shell
python -m pip install visualdl -i https://mirror.baidu.com/pypi/simple
```
### 使用代码安装
```
git clone https://github.com/PaddlePaddle/VisualDL.git
cd VisualDL
python setup.py bdist_wheel
pip install --upgrade dist/visualdl-*.whl
```
需要注意,官方自2020年1月1日起不再维护Python2,为了保障代码可用性,VisualDL现仅支持Python3
## 使用方式
VisualDL将训练过程中的数据、参数等信息储存至日志文件中后,启动面板即可查看可视化结果。
### 1. 记录日志
VisualDL的后端提供了Python SDK,可通过LogWriter定制一个日志记录器,接口如下:
```python
class LogWriter(logdir=None,
comment='',
max_queue=10,
flush_secs=120,
filename_suffix='',
write_to_disk=True,
display_name='',
**kwargs)
```
#### 接口参数
| 参数 | 格式 | 含义 |
| --------------- | ------- | ------------------------------------------------------------ |
| logdir | string | 日志文件所在的路径,VisualDL将在此路径下建立日志文件并进行记录,如果不填则默认为`runs/${CURRENT_TIME}` |
| comment | string | 为日志文件夹名添加后缀,如果制定了logdir则此项无效 |
| max_queue | int | 日志记录消息队列的最大容量,默认值为10,达到此容量则立即写入到日志文件,如果设置为0则不缓存 |
| flush_secs | int | 日志记录消息队列的最大缓存时间,默认值为120,达到此时间则立即写入到日志文件,如果设置为0则不缓存 |
| filename_suffix | string | 为默认的日志文件名添加后缀 |
| write_to_disk | boolean | 是否写入到磁盘 |
| display_name | string | 在面板中`选择数据流`位置显示此参数,如不指定则默认显示日志所在路径(当日志所在路径过长或想隐藏日志所在路径时可指定此参数) |
#### 示例
设置日志文件并记录标量数据:
```python
from visualdl import LogWriter
# 在`./log/scalar_test/train`路径下建立日志文件
with LogWriter(logdir="./log/scalar_test/train") as writer:
# 使用scalar组件记录一个标量数据
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. 启动面板
在上述示例中,日志已记录三组标量数据,现可启动VisualDL面板查看日志的可视化结果,共有两种启动方式:
#### 在命令行启动
使用命令行启动VisualDL面板,命令格式如下:
```python
visualdl --logdir <dir_1, dir_2, ... , dir_n> --host <host> --port <port> --cache-timeout <cache_timeout> --language <language> --public-path <public_path> --api-only
```
参数详情:
| 参数 | 意义 |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --logdir | 设定日志所在目录,可以指定多个目录,VisualDL将遍历并且迭代寻找指定目录的子目录,将所有实验结果进行可视化 |
| --model | 设定模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化,目前可支持PaddlePaddle、ONNX、Keras、Core ML、Caffe等多种模型结构,详情可查看[graph支持模型种类](./docs/components/README.md#%E5%8A%9F%E8%83%BD%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E-2) |
| --host | 设定IP,默认为`127.0.0.1` |
| --port | 设定端口,默认为`8040` |
| --cache-timeout | 后端缓存时间,在缓存时间内前端多次请求同一url,返回的数据从缓存中获取,默认为20秒 |
| --language | VisualDL面板语言,可指定为'en'或'zh',默认为浏览器使用语言 |
| --public-path | VisualDL面板URL路径,默认是'/app',即访问地址为'http://&lt;host&gt;:&lt;port&gt;/app' |
| --api-only | 是否只提供API,如果设置此参数,则VisualDL不提供页面展示,只提供API服务,此时API地址为'http://&lt;host&gt;:&lt;port&gt;/&lt;public_path&gt;/api';若没有设置public_path参数,则默认为'http://&lt;host&gt;:&lt;port&gt;/api' |
针对上一步生成的日志,启动命令为:
```
visualdl --logdir ./log
```
#### 在Python脚本中启动
支持在Python脚本中启动VisualDL面板,接口如下:
```python
visualdl.server.app.run(logdir,
host="127.0.0.1",
port=8080,
cache_timeout=20,
language=None,
public_path=None,
api_only=False,
open_browser=False)
```
请注意:除`logdir`外,其他参数均为不定参数,传递时请指明参数名。
接口参数具体如下:
| 参数 | 格式 | 含义 |
| ------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| logdir | string或list[string_1, string_2, ... , string_n] | 日志文件所在的路径,VisualDL将在此路径下递归搜索日志文件并进行可视化,可指定单个或多个路径 |
| model | string | 模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化 |
| host | string | 指定启动服务的ip,默认为`127.0.0.1` |
| port | int | 启动服务端口,默认为`8040` |
| cache_timeout | int | 后端缓存时间,在缓存时间内前端多次请求同一url,返回的数据从缓存中获取,默认为20秒 |
| language | string | VisualDL面板语言,可指定为'en'或'zh',默认为浏览器使用语言 |
| public_path | string | VisualDL面板URL路径,默认是'/app',即访问地址为'http://&lt;host&gt;:&lt;port&gt;/app' |
| api_only | boolean | 是否只提供API,如果设置此参数,则VisualDL不提供页面展示,只提供API服务,此时API地址为'http://&lt;host&gt;:&lt;port&gt;/&lt;public_path&gt;/api';若没有设置public_path参数,则默认为'http://&lt;host&gt;:&lt;port&gt;/api' |
| open_browser | boolean | 是否打开浏览器,设置为True则在启动后自动打开浏览器并访问VisualDL面板,若设置api_only,则忽略此参数 |
针对上一步生成的日志,我们的启动脚本为:
```python
from visualdl.server import app
app.run(logdir="./log")
```
在使用任意一种方式启动VisualDL面板后,打开浏览器访问VisualDL面板,即可查看日志的可视化结果,如图:
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/82786044-67ae9880-9e96-11ea-8a2b-3a0951a6ec19.png" width="60%"/>
</p>
## 可视化功能概览
### Scalar
以图表形式实时展示训练过程参数,如loss、accuracy。让用户通过观察单组或多组训练参数变化,了解训练过程,加速模型调优。具有两大特点:
#### 动态展示
在启动VisualDL Board后,LogReader将不断增量的读取日志中数据并供前端调用展示,因此能够在训练中同步观测指标变化,如下图:
<p align="center">
<img src="https://visualdl.bj.bcebos.com/images/dynamic_display.gif" width="60%"/>
</p>
#### 多实验对比
只需在启动VisualDL Board的时将每个实验日志所在路径同时传入即可,每个实验中相同tag的指标将绘制在一张图中同步呈现,如下图:
<p align="center">
<img src="https://visualdl.bj.bcebos.com/images/multi_experiments.gif" width="100%"/>
</p>
### Image
实时展示训练过程中的图像数据,用于观察不同训练阶段的图像变化,进而深入了解训练过程及效果。
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90356439-24715980-e082-11ea-8896-01c27fc2fc9b.gif" width="85%"/>
</p>
### Audio
实时查看训练过程中的音频数据,监控语音识别与合成等任务的训练过程。
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/87659138-b4746880-c78f-11ea-965b-c33804e7c296.png" width="85%"/>
</p>
### Graph
一键可视化模型的网络结构。可查看模型属性、节点信息、节点输入输出等,并支持节点搜索,辅助用户快速分析模型结构与了解数据流向。
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84483052-5acdd980-accb-11ea-8519-1608da7ee698.png" width="85%"/>
</p>
### Histogram
以直方图形式展示Tensor(weight、bias、gradient等)数据在训练过程中的变化趋势。深入了解模型各层效果,帮助开发者精准调整模型结构。
- Offset模式
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86551031-86647c80-bf76-11ea-8ec2-8c86826c8137.png" width="85%"/>
</p>
- Overlay模式
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86551033-882e4000-bf76-11ea-8e6a-af954c662ced.png" width="85%"/>
</p>
### PR Curve
精度-召回率曲线,帮助开发者权衡模型精度和召回率之间的平衡,设定最佳阈值。
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86738774-ee46c000-c067-11ea-90d2-a98aac445cca.png" width="85%"/>
</p>
### High Dimensional
将高维数据进行降维展示,目前支持T-SNE、PCA两种降维方式,用于深入分析高维数据间的关系,方便用户根据数据特征进行算法优化。
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/82396340-3e4dd100-9a80-11ea-911d-798acdbc9c90.gif" width="85%"/>
</p>
### VDL.service
VisualDL可视化结果保存服务,以链接形式将可视化结果保存下来,方便用户快速、便捷的进行托管与分享。
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93729521-72382f00-fbf7-11ea-91ff-6b6ab4b41e32.png" width="85%"/>
</p>
## 开源贡献
VisualDL 是由 [PaddlePaddle](https://www.paddlepaddle.org/)[ECharts](https://echarts.apache.org/) 合作推出的开源项目。
Graph 相关功能由 [Netron](https://github.com/lutzroeder/netron) 提供技术支持。
欢迎所有人使用,提意见以及贡献代码。
## 更多细节
想了解更多关于VisualDL可视化功能的使用详情介绍,请查看[**VisualDL使用指南**](./docs/components/README.md)
## 技术交流
欢迎您加入VisualDL官方QQ群:1045783368 与飞桨团队以及其他用户共同针对VisualDL进行讨论与交流。
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/82522691-c2758680-9b5c-11ea-9aee-fca994aba175.png" width="20%"/>
</p>
[**English**](./UserGuide-en.md) [**中文**](./README_CN.md)
# VisualDL 使用指南
### 概述 # VisualDL Guide
VisualDL 是一个面向深度学习任务设计的可视化工具。VisualDL 利用了丰富的图表来展示数据,用户可以更直观、清晰地查看数据的特征与变化趋势,有助于分析数据、及时发现错误,进而改进神经网络模型的设计。 ### Overview
目前,VisualDL 支持 scalar, image, audio,graph, histogram, pr curve, ROC curve, high dimensional 七个组件,项目正处于高速迭代中,敬请期待新组件的加入。 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 seven components: scalar, image, audio, graph, histogram, pr curve, ROC curve and high dimensional. VisualDL iterates rapidly and new functions will be continuously added.
| :----------------------------------------------------------: | :--------: | :----------------------------------------------------------- |
| [ Scalar](#Scalar--标量组件) | 折线图 | 动态展示损失函数值、准确率等标量数据 |
| [Image](#Image--图片可视化组件) | 图片可视化 | 显示图片,可显示输入图片和处理后的结果,便于查看中间过程的变化 |
| [Audio](#Audio--音频播放组件) | 音频可视化 | 播放训练过程中的音频数据,监控语音识别与合成等任务的训练过程 |
| [Text](#Text--文本组件) | 文本可视化 | 展示文本任务任意阶段的数据输出,对比不同阶段的文本变化,便于深入了解训练过程及效果。 |
| [Graph](#Graph--网络结构组件) | 网络结构 | 展示网络结构、节点属性及数据流向,辅助学习、优化网络结构 |
| [Histogram](#Histogram--直方图组件) | 直方图 | 展示训练过程中权重、梯度等张量的分布 |
| [PR Curve](#PR-Curve--PR曲线组件) | 折线图 | 权衡精度与召回率之间的平衡关系 |
| [ROC Curve](#ROC-Curve--ROC曲线组件) | 折线图 | 展示不同阈值下的模型表现 |
| [High Dimensional](#High-Dimensional--数据降维组件) | 数据降维 | 将高维数据映射到 2D/3D 空间来可视化嵌入,便于观察不同数据的相关性 |
同时,VisualDL提供可视化结果保存服务,通过 [VDL.service](#vdlservice) 生成链接,保存并分享可视化结果
## Scalar--标量组件
### 介绍 | Component Name | Display Chart | Function |
| :----------------------------------------------------------: | :---------------------------: | :----------------------------------------------------------- |
| [ 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. |
| [Audio](#Audio--Audio-Play) | Audio Play | Play the audio during the training process, making it easy to monitor the process of speech recognition and text-to-speech. |
| [Text](#Text) | Text Visualization | Visualizes the text output of NLP models within any stage, aiding developers to compare the changes of outputs so as to deeply understand the training process and simply evaluate the performance of the model. |
| [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. |
| [PR Curve](#PR-Curve) | Precision & Recall Curve | Display precision-recall curves across training steps, clarifying the tradeoff between precision and recall when comparing models. |
| [ROC Curve](#ROC-Curve) | Receiver Operating Characteristic curve | Shows the performance of a classification model at all classification thresholds. |
| [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 组件的输入数据类型为标量,该组件的作用是将训练参数以折线图形式呈现。将损失函数值、准确率等标量数据作为参数传入 scalar 组件,即可画出折线图,便于观察变化趋势。 At the same time, VisualDL provides [VDL.service](#vdlservice) , which allows developers to easily save, track and share visualization results of experiments with anyone for free.
### 记录接口 ## Scalar--Line Chart
Scalar 组件的记录接口如下: ### 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 ```python
add_scalar(tag, value, step, walltime=None) add_scalar(tag, value, step, walltime=None)
``` ```
接口参数说明如下: The interface parameters are described as follows:
| 参数 | 格式 | 含义 | | parameter | format | meaning |
| -------- | ------ | ------------------------------------------- | | --------- | ------ | ------------------------------------------------------------ |
| tag | string | 记录指标的标志,如`train/loss`,不能含有`%` | | tag | string | Record the name of the scalar data,e.g.train/loss. Notice that the name cannot contain `%` |
| value | float | 要记录的数据值 | | value | float | Record the data, can't be `None` |
| step | int | 记录的步数 | | step | int | Record the training steps. The data will be sampled, meaning that only part of data will be displayed. (the sampling algorithm is reservoir sampling, details can be refered to [VisualDL sampling algorithm](../faq.md/#what-are-the-sampling-rules-of-visualdl)) |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 | | walltime | int | Record the time-stamp of the data, the default is the current time-stamp |
*注意tag的使用规则为: *Note that the rules of specifying tags (e.g.train/acc) are:
1. 第一个`/`前的为父tag,并作为一栏图片的tag 1. The tag before the first `/` is the parent tag and serves as the tag of the same raw
2. 第一个`/`后的为子tag,子tag的对应图片将显示在父tag下 2. The tag after the first `/` is a child tag, the charts with child tag will be displayed under the parent tag. The data of the same parent tag but different child tags will be displayed in the same column, but not in the same picture.
3. 可以使用多次`/`,但一栏图片的tag依旧为第一个`/`前的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:
- 创建train为父tag,acc和loss为子tag:`train/acc``train/loss`,即创建了tag为train的图片栏,包含acc和loss两张图表: - 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':
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84653342-d6d05780-af3f-11ea-8979-8da039ae7201.JPG" width="100%"/> <img src="https://user-images.githubusercontent.com/48054808/90884030-88c54d80-e3e1-11ea-9ba7-4b8df7b3496e.png" width="100%"/>
</p> </p>
- 创建train为父tag,test/acc和test/loss为子tag:`train/test/acc``train/test/loss`,即创建了tag为train的图片栏,包含test/acc和test/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':
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84644066-3bd08100-af31-11ea-8eb5-c4a4cab351ed.png" width="100%"/> <img src="https://user-images.githubusercontent.com/48054808/90884098-a692b280-e3e1-11ea-8c0b-380b970b50b2.png" width="100%"/>
</p> </p>
- 创建两个父tag:`acc``loss`,即创建了tag分别为acc和loss的两个图表栏:: - When two parent tags are created:`acc``loss`, two rows of charts are named as 'acc' and 'loss' respectively.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84644323-99fd6400-af31-11ea-9855-eca7f7b01810.png" width="100%"/> <img src="https://user-images.githubusercontent.com/48054808/90884122-b3afa180-e3e1-11ea-90b0-93a75543f253.png" width="100%"/>
</p> </p>
### Demo ### Demo
- 基础使用 - Fundamental Methods
下面展示了使用 Scalar 组件记录数据的示例,代码见[Scalar组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/scalar_test.py) The following shows an example of using Scalar to record data, and the script can be found in [Scalar Demo](../../demo/components/scalar_test.py)
```python ```python
from visualdl import LogWriter from visualdl import LogWriter
if __name__ == '__main__': if __name__ == '__main__':
value = [i/1000.0 for i in range(1000)] value = [i/1000.0 for i in range(1000)]
# 初始化一个记录器 # initialize a recorder
with LogWriter(logdir="./log/scalar_test/train") as writer: with LogWriter(logdir="./log/scalar_test/train") as writer:
for step in range(1000): for step in range(1000):
# 向记录器添加一个tag为`acc`的数据 # add accuracy with tag of 'acc' to the recorder
writer.add_scalar(tag="acc", step=step, value=value[step]) writer.add_scalar(tag="acc", step=step, value=value[step])
# 向记录器添加一个tag为`loss`的数据 # add loss with tag of 'loss' to the recorder
writer.add_scalar(tag="loss", step=step, value=1/(value[step] + 1)) writer.add_scalar(tag="loss", step=step, value=1/(value[step] + 1))
``` ```
运行上述程序后,在命令行执行 After running the above program, developers can launch the panel by:
```shell ```shell
visualdl --logdir ./log --port 8080 visualdl --logdir ./log --port 8080
``` ```
接着在浏览器打开`http://127.0.0.1:8080`,即可查看以下折线图。 Then, open the browser and enter the address: `http://127.0.0.1:8080`to view line charts:
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93732057-36ef2d80-fc02-11ea-9dac-b8fdce194d09.png" width="100%"/> <img src="https://user-images.githubusercontent.com/48054808/90871520-c9b36700-e3cd-11ea-9063-ca692b1d3917.png" width="100%"/>
</p> </p>
- 多组实验对比 - Advanced Usage--Comparison of Multiple Experiments
下面展示了使用Scalar组件实现多组实验对比 The following shows the comparison of multiple sets of experiments using Scalar.
多组实验对比的实现分为两步: There are two steps to achieve this function:
1. 创建子日志文件储存每组实验的参数数据 1. Create sub-log files to store the parameter data of each group of experiments
2. 将数据写入scalar组件时,**使用相同的tag**,即可实现对比**不同实验****同一类型参数** 2. When recording data to the scalar component,developers can compare **the same type of parameters for different experiments** by **using the same tag**. Note that the log files you want to display must be placed in different directories because only one log file in a directory is valid and displayed.
```python ```python
from visualdl import LogWriter from visualdl import LogWriter
if __name__ == '__main__': if __name__ == '__main__':
value = [i/1000.0 for i in range(1000)] value = [i/1000.0 for i in range(1000)]
# 步骤一:创建父文件夹:log与子文件夹:scalar_test # Step 1: Create a parent folder: log and a child folder: scalar_test
with LogWriter(logdir="./log/scalar_test") as writer: with LogWriter(logdir="./log/scalar_test") as writer:
for step in range(1000): for step in range(1000):
# 步骤二:向记录器添加一个tag为`train/acc`的数据 # Step 2: Add data with tag train/acc to the recorder
writer.add_scalar(tag="train/acc", step=step, value=value[step]) writer.add_scalar(tag="train/acc", step=step, value=value[step])
# 步骤二:向记录器添加一个tag为`train/loss`的数据 # Step 2: Add data with tag train/loss to the recorder
writer.add_scalar(tag="train/loss", step=step, value=1/(value[step] + 1)) writer.add_scalar(tag="train/loss", step=step, value=1/(value[step] + 1))
# 步骤一:创建第二个子文件夹scalar_test2 # Step 1: Create a second child folder: scalar_test2
value = [i/500.0 for i in range(1000)] value = [i/500.0 for i in range(1000)]
with LogWriter(logdir="./log/scalar_test2") as writer: with LogWriter(logdir="./log/scalar_test2") as writer:
for step in range(1000): for step in range(1000):
# 步骤二:在同样名为`train/acc`下添加scalar_test2的accuracy的数据 # Step 2: Add the accuracy data of scalar_test2 under the same name `train/acc`
writer.add_scalar(tag="train/acc", step=step, value=value[step]) writer.add_scalar(tag="train/acc", step=step, value=value[step])
# 步骤二:在同样名为`train/loss`下添加scalar_test2的loss的数据 # Step 2: Add the loss data of scalar_test2 under the same name as `train/loss`
writer.add_scalar(tag="train/loss", step=step, value=1/(value[step] + 1)) writer.add_scalar(tag="train/loss", step=step, value=1/(value[step] + 1))
``` ```
运行上述程序后,在命令行执行 After running the above program, developers can launch the panel by:
```shell ```shell
visualdl --logdir ./log --port 8080 visualdl --logdir ./log --port 8080
``` ```
接着在浏览器打开`http://127.0.0.1:8080`,即可查看以下折线图,观察scalar_test和scalar_test2的accuracy和loss的对比。 Then, open the browser and enter the address: `http://127.0.0.1:8080` to view line charts:
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84644158-5efb3080-af31-11ea-8e64-bbe4078425f4.png" width="100%"/> <img src="https://user-images.githubusercontent.com/48054808/90884963-4dc41980-e3e3-11ea-824a-277a8d71823e.png" width="100%"/>
</p> </p>
*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)
It can be seen that the data of different experiments (determined by the path) are displayed in different pictures, and the data of the same tag is displayed on the same picture for comparison.
*多组实验对比的应用案例可参考AI Studio项目:[VisualDL 2.0--眼疾识别训练可视化](https://aistudio.baidu.com/aistudio/projectdetail/502834) ### Functional Instruction
### 功能操作说明
* 支持数据卡片「最大化」、「还原」、「坐标系转化」(y轴对数坐标)、「下载」折线图 * Developers are allowed to zoom in, restore, transform of the coordinate axis (y-axis logarithmic coordinates), download the line chart.
<p align="center"> <p align="center">
<img src="https://visualdl.bj.bcebos.com/images/scalar-icon.png" width="55%"/> <img src="https://visualdl.bj.bcebos.com/images/scalar-icon.png" width="45%"/>
</p> </p>
* 数据点Hover展示详细信息 * Details can be shown by hovering on specific data points.
<p align="center"> <p align="center">
<img src="https://visualdl.bj.bcebos.com/images/scalar-tooltip.png" width="60%"/> <img src="https://user-images.githubusercontent.com/48054808/90872099-b785f880-e3ce-11ea-9ebe-8083c893d88b.png" width="60%"/>
</p> </p>
* 可搜索卡片标签,展示目标图像 * Developers can find target scalar charts by searching corresponded tags.
<p align="center"> <p align="center">
<img src="https://visualdl.bj.bcebos.com/images/scalar-searchlabel.png" width="90%"/> <img src="https://user-images.githubusercontent.com/48054808/90872849-cfaa4780-e3cf-11ea-985d-b4c382acf773.png" width="90%"/>
</p> </p>
* 可搜索打点数据标签,展示特定数据 * Specific runs can be selected by searching for the corresponded experiment tags.
<p align="center"> <p align="center">
<img src="https://visualdl.bj.bcebos.com/images/scalar-searchstream.png" width="40%"/> <img src="https://user-images.githubusercontent.com/48054808/90873112-2b74d080-e3d0-11ea-8a69-24b7b4abae96.png" width="40%"/>
</p> </p>
* 选择显示最值,展示最大最小值以及对应的训练步数 * Display the global extrema
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93732336-65213d00-fc03-11ea-96f4-cc6497094a06.png" width="20%"/> <img src="https://user-images.githubusercontent.com/48054808/93732753-46bc4100-fc05-11ea-92ca-35c89467815b.png" width="30%"/>
</p> </p>
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93732424-d8c34a00-fc03-11ea-8b7b-0a728274f50f.png" width="60%"/> <img src="https://user-images.githubusercontent.com/48054808/93732766-58054d80-fc05-11ea-89e0-bc00a283f559.png" width="60%"/>
</p> </p>
* 选择仅显示平滑后的数据 * Only display smoothed data
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93732485-263fb700-fc04-11ea-9edb-40cb8676aad0.png" width="25%"/> <img src="https://user-images.githubusercontent.com/48054808/93732799-7f5c1a80-fc05-11ea-886f-193c3bcc9b5f.png" width="30%"/>
</p> </p>
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93732514-4cfded80-fc04-11ea-99c9-9053f9945c8b.png" width="60%"/> <img src="https://user-images.githubusercontent.com/48054808/93732815-9569db00-fc05-11ea-8353-ffa5086d3d52.png" width="60%"/>
</p> </p>
* X轴有三种衡量尺度 * There are three measurement scales of X axis
1. Step:迭代次数 1. Step: number of iterations
2. Walltime:训练绝对时间 2. Walltime: absolute training time
3. Relative:训练时长 3. Relative: training time
<p align="center"> <p align="center">
<img src="https://visualdl.bj.bcebos.com/images/x-axis.png" width="40%"/> <img src="https://user-images.githubusercontent.com/48054808/90873502-da191100-e3d0-11ea-8b03-c8fea0b65388.png" width="40%"/>
</p> </p>
* 可调整曲线平滑度,以便更好的展现参数整体的变化趋势
* The smoothness of the curve can be adjusted to better show the change of the overall trend.
<p align="center"> <p align="center">
<img src="https://visualdl.bj.bcebos.com/images/scalar-smooth.png" width="37%"/> <img src="https://user-images.githubusercontent.com/48054808/90873564-edc47780-e3d0-11ea-909c-161e9fd8eeef.png" width="37%"/>
</p> </p>
## Image--图片可视化组件 ## Image--Image Visualization
### 介绍 ### Introduction
Image 组件用于显示图片数据随训练的变化。在模型训练过程中,将图片数据传入 Image 组件,就可在 VisualDL 的前端网页查看相应图片。 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
Image 组件的记录接口如下: The interface of the Image is shown as follows:
```python ```python
add_image(tag, img, step, walltime=None, dataformats="HWC") add_image(tag, img, step, walltime=None, dataformats="HWC")
``` ```
接口参数说明如下: The interface parameters are described as follows:
| 参数 | 格式 | 含义 | | parameter | format | meaning |
| -------- | ------------- | ------------------------------------------- | | --------- | ------------- | ------------------------------------------------------------ |
| tag | string | 记录指标的标志,如`train/loss`,不能含有`%` | | tag | string | Record the name of the image data,e.g.train/loss. Notice that the name cannot contain `%` |
| img | numpy.ndarray | 以ndarray格式表示的图片 | | img | numpy.ndarray | Images in ndarray format. The default `HWC` format dimension is [h, w, c], h and w are the height and width of the images, and c is the number of channels, which can be 1, 3, 4. Floating point data will be clipped to the range[0, 1), and note that the image data cannot be None. |
| step | int | 记录的步数 | | step | int | Record the training steps |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 | | walltime | int | Record the time-stamp of the data, the default is the current time-stamp |
| dataformats| string | 传入的图片格式,包括`NCHW``HWC``HW`,默认为`HWC`| | dataformats| string | Format of image,include `NCHW`、`NHWC`、`HWC`、`CHW`、`HW`,default is `HWC`. It will be converted to `HWC` format when stored.|
### Demo ### Demo
下面展示了使用 Image 组件记录数据的示例,代码文件请见[Image组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/image_test.py) 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).
```python ```python
import numpy as np import numpy as np
from PIL import Image from PIL import Image
...@@ -243,7 +246,7 @@ from visualdl import LogWriter ...@@ -243,7 +246,7 @@ from visualdl import LogWriter
def random_crop(img): def random_crop(img):
"""获取图片的随机 100x100 分片 """get random 100x100 slices of image
""" """
img = Image.open(img) img = Image.open(img)
w, h = img.size w, h = img.size
...@@ -254,124 +257,65 @@ def random_crop(img): ...@@ -254,124 +257,65 @@ def random_crop(img):
if __name__ == '__main__': if __name__ == '__main__':
# 初始化一个记录器 # initialize a recorder
with LogWriter(logdir="./log/image_test/train") as writer: with LogWriter(logdir="./log/image_test/train") as writer:
for step in range(6): for step in range(6):
# 添加一个图片数据 # add image data
writer.add_image(tag="eye", writer.add_image(tag="eye",
img=random_crop("../../docs/images/eye.jpg"), img=random_crop("../../docs/images/eye.jpg"),
step=step) step=step)
``` ```
运行上述程序后,在命令行执行 After running the above program, developers can launch the panel by:
```shell ```shell
visualdl --logdir ./log --port 8080 visualdl --logdir ./log --port 8080
``` ```
在浏览器输入`http://127.0.0.1:8080`,即可查看图片数据。 Then, open the browser and enter the address: `http://127.0.0.1:8080`to view:
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/82397685-86babe00-9a83-11ea-870e-502f313bdc7c.png" width="90%"/> <img src="https://user-images.githubusercontent.com/48054808/90874434-4a746200-e3d2-11ea-9395-a039d9e83470.png" width="90%"/>
</p> </p>
### 功能操作说明 ### Functional Instructions
- 可搜索图片标签显示对应图片数据 - Developers can find target images by searching corresponded tags.
<p align="center"> <p align="center">
<img src="https://visualdl.bj.bcebos.com/images/image-search.png" width="90%"/> <img src="https://user-images.githubusercontent.com/48054808/90875589-f8344080-e3d3-11ea-9020-52a5a88324ab.png" width="90%"/>
</p> </p>
- 支持滑动Step/迭代次数查看不同迭代次数下的图片数据 - Developers are allowed to view image data under different iterations by scrolling the Step/iteration slider.
<p align="center">
<img src="https://visualdl.bj.bcebos.com/images/image-eye.gif" width="60%"/>
</p>
### 添加图片矩阵
除使用add_image记录一张图片之外,还可以使用add_image_matrix一次添加多张图片并生成一张图片矩阵,接口及参数说明如下:
add_image_matrix的记录接口如下:
```python
add_image_matrix(tag, imgs, step, rows=-1, scale=1, walltime=None, dataformats="HWC")
```
接口参数说明如下:
| 参数 | 格式 | 含义 |
| -------- | ------------- | ------------------------------------------- |
| tag | string | 记录指标的标志,如`train/loss`,不能含有`%` |
| imgs | numpy.ndarray | 以ndarray格式表示的多张图片,第一维为图片的数量 |
| step | int | 记录的步数 |
| rows | int | 生成图片矩阵的行数,默认值为-1,表示尽量把传入的图片组合成行列数相近的形式 |
| scale | int | 图片放大比例,默认为1 |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 |
| dataformats| string | 传入的图片格式,包括`NCHW``HWC``HW`,默认为`HWC`|
**PS:当给定的子图像数量不足时,将用空白图像填充,以保证生成的图形为完整矩形**
#### Demo
下面展示了使用 Image 组件合成并记录多张图片数据的示例,代码文件请见[Image组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/image_matrix_test.py)
```python
import numpy as np
from PIL import Image
from visualdl import LogWriter
if __name__ == '__main__':
imgs = []
for index in range(6):
imgs.append(np.asarray(Image.open("../../docs/images/images_matrix/%s.jpg" % str((index)))))
with LogWriter(logdir='./log/image_matrix_test/train') as writer:
writer.add_image(tag='detection', step=0, img=imgs[0])
# 合成长宽尽量接近的图形矩阵,本例生成3X2的矩阵
writer.add_image_matrix(tag='detection', step=1, imgs=imgs, rows=-1)
# 合成长为1的图形矩阵,本例生成1x6的矩阵
writer.add_image_matrix(tag='detection', step=2, imgs=imgs, rows=1)
# 合成长为2的图形矩阵,本例生成2X3的矩阵
writer.add_image_matrix(tag='detection', step=3, imgs=imgs, rows=2)
# 合成长为3的图形矩阵,本例生成3X2的矩阵
writer.add_image_matrix(tag='detection', step=4, imgs=imgs, rows=3)
# 合成长为4的图形矩阵,本例生成4X2的矩阵,自动补充子图像填充第四行
writer.add_image_matrix(tag='detection', step=5, imgs=imgs, rows=4)
```
运行上述程序后,在命令行执行
```shell
visualdl --logdir ./log --port 8080
```
在浏览器输入`http://127.0.0.1:8080`,即可查看图片数据。
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/28444161/106742199-aae11e00-6657-11eb-827a-c785f9ff336e.png" width="40%"/> <img src="https://user-images.githubusercontent.com/48054808/90875652-10a45b00-e3d4-11ea-9fd9-3c79f22829f7.gif" width="60%"/>
<img src="https://user-images.githubusercontent.com/28444161/106742248-c0eede80-6657-11eb-9c9e-3e858ae6562d.png" width="40%"/>
</p> </p>
## Audio--Audio Play
## Audio--音频播放组件 ### Introduction
### 介绍
Audio组件实时查看训练过程中的音频数据,监控语音识别与合成等任务的训练过程。 Audio aims to allow developers to listen to the audio in real-time during the training process, helping developers to monitor the process of speech recognition and text-to-speech.
### 记录接口 ### Record Interface
Audio 组件的记录接口如下: The interface of the Image is shown as follows:
```python ```python
add_audio(tag, audio_array, step, sample_rate) add_audio(tag, audio_array, step, sample_rate)
``` ```
接口参数说明如下: The interface parameters are described as follows:
| 参数 | 格式 | 含义 | | parameter | format | meaning |
| -------- | ------------- | ------------------------------------------- | | --------- | ------------- | ------------------------------------------------------------ |
| tag | string | 记录指标的标志,如`audio_tag`,不能含有`%` | | tag | string | Record the name of the audio,e.g.audoi/sample. Notice that the name cannot contain `%` |
| audio_arry | numpy.ndarray | 以ndarray格式表示的音频 | | audio_arry | numpy.ndarray | Audio in ndarray format, whose elements are float values, and the range should be normalized in [-1, 1] |
| step | int | 记录的步数 | | step | int | Record the training steps |
| sample_rate | int | 采样率,**注意正确填写对应音频的采样率** | | sample_rate | int | Sample rate,the default sampling rate is 8000. **Please note that the rate should be the rate of the original audio** |
### Demo ### Demo
下面展示了使用 Audio 组件记录数据的示例,代码文件请见[Audio组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/audio_test.py) The following shows an example of using Audio to record data, and the script can be found in [Audio Demo](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/audio_test.py).
```python ```python
from visualdl import LogWriter from visualdl import LogWriter
from scipy.io import wavfile from scipy.io import wavfile
...@@ -385,76 +329,75 @@ if __name__ == '__main__': ...@@ -385,76 +329,75 @@ if __name__ == '__main__':
step=0, step=0,
sample_rate=sample_rate) sample_rate=sample_rate)
``` ```
After running the above program, developers can launch the panel by:
运行上述程序后,在命令行执行
```shell ```shell
visualdl --logdir ./log --port 8080 visualdl --logdir ./log --port 8080
``` ```
在浏览器输入`http://127.0.0.1:8080`,即可查看音频数据。 Then, open the browser and enter the address: `http://127.0.0.1:8080`to view:
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/87659138-b4746880-c78f-11ea-965b-c33804e7c296.png" width="90%"/> <img src="https://user-images.githubusercontent.com/48054808/88753858-eaeab400-d18f-11ea-87c6-46ab7d5a5fd0.png" width="90%"/>
</p> </p>
### 功能操作说明 ### Functional Instructions
- 可搜索音频标签显示对应音频数据 - Developers can find the target audio by searching corresponded tags.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/87661431-29956d00-c793-11ea-833b-172d8fc1b221.png" width="80%"/> <img src="https://user-images.githubusercontent.com/48054808/88755034-c6dca200-d192-11ea-8349-1414bcf9d38d.png" width="80%"/>
</p> </p>
- 支持滑动Step/迭代次数查看不同迭代次数下的音频数据 - Developers are allowed to listen to the audio under different iterations by scrolling the Step/iteration slider.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/87661089-a07e3600-c792-11ea-8740-cbe99a64d830.png" width="40%"/> <img src="https://user-images.githubusercontent.com/48054808/88755220-33f03780-d193-11ea-9b0f-a283d9f3a78a.png" width="40%"/>
</p> </p>
- 支持播放/暂停音频数据 - Play/Pause the audio
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/87661130-b3910600-c792-11ea-9f9f-2ae66132e9de.png" width="40%"/> <img src="https://user-images.githubusercontent.com/48054808/88755240-41a5bd00-d193-11ea-9780-7ae7c7792070.png" width="40%"/>
</p> </p>
- 支持音量调节 - Adjust the volume
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/87661497-49c52c00-c793-11ea-9eeb-471543cd2a0b.png" width="40%"/> <img src="https://user-images.githubusercontent.com/48054808/88755258-53876000-d193-11ea-96b2-9ed698423202.png" width="40%"/>
</p> </p>
- 支持音频下载 - Download the audio
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/87661166-c277b880-c792-11ea-8ad7-5c60bb08379b.png" width="40%"/> <img src="https://user-images.githubusercontent.com/48054808/88755377-9a755580-d193-11ea-947e-4275b9d3aa54.png" width="40%"/>
</p> </p>
## Text--文本组件 ## Text
### 介绍 ### Introduction
Text展示文本任务任意阶段的数据输出,对比不同阶段的文本变化,便于深入了解训练过程及效果。 visualizes the text output of NLP models within any stage, aiding developers to compare the changes of outputs so as to deeply understand the training process and simply evaluate the performance of the model.
### 记录接口 ### Record Interface
Text组件的记录接口如下: The interface of the Text is shown as follows:
```python ```python
add_text(tag, text_string, step=None, walltime=None) add_text(tag, text_string, step=None, walltime=None)
``` ```
接口参数说明如下: The interface parameters are described as follows:
| 参数 | 格式 | 含义 | | parameter | format | meaning |
| -------------- | --------------------- | ------------------------------------------- | | -------------- | --------------------- | ------------------------------------------- |
| tag | string | 记录指标的标志,如`train/loss`,不能含有`%` | | tag | string | Record the name of the text data,e.g.train/loss. Notice that the name cannot contain `%` |
| text_string | string | 文本字符串 | | text_string | string | Value of text |
| step | int | 记录的步数 | | step | int | Record the training steps |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 | | walltime | int | Record the time-stamp of the data, and the default is the current time-stamp |
### Demo ### Demo
下面展示了使用 Text 组件记录数据的示例,代码见[Text组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/text_test.py) The following shows an example of how to use Text component, and script can be found in [Text Demo](../../demo/components/text_test.py)
```python ```python
from visualdl import LogWriter from visualdl import LogWriter
...@@ -472,154 +415,152 @@ if __name__ == '__main__': ...@@ -472,154 +415,152 @@ if __name__ == '__main__':
writer.add_text(tag="output", step=step, text_string=texts[step]) writer.add_text(tag="output", step=step, text_string=texts[step])
``` ```
运行上述程序后,在命令行执行 After running the above program, developers can launch the panel by:
```shell ```shell
visualdl --logdir ./log --port 8080 visualdl --logdir ./log --port 8080
``` ```
接着在浏览器打开`http://127.0.0.1:8080`,即可查看Text Then, open the browser and enter the address`http://127.0.0.1:8080` to view:
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/28444161/106248340-cdd09400-624b-11eb-8ea9-5a07a239c365.png" width="95%"/> <img src="https://user-images.githubusercontent.com/28444161/106248340-cdd09400-624b-11eb-8ea9-5a07a239c365.png" width="95%"/>
</p> </p>
### 功能操作说明 ### Functional Instrucions
- 可搜索文本标签显示对应文本数据 - Developers can find the target text by searching corresponded tags.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536503-baaa4f80-bf1a-11ea-80ab-cd988617d018.png" width="40%"/> <img src="https://user-images.githubusercontent.com/48054808/86536503-baaa4f80-bf1a-11ea-80ab-cd988617d018.png" width="40%"/>
</p> </p>
- 可搜索数据流标签显示对应数据流数据 - Developers can find the target runs by searching corresponded tags.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/28444161/106256983-f4e09300-6256-11eb-9acc-a24a2ac9b70c.png" width="40%"/> <img src="https://user-images.githubusercontent.com/28444161/106256983-f4e09300-6256-11eb-9acc-a24a2ac9b70c.png" width="40%"/>
</p> </p>
- 可折叠标签 - Developers can fold the tab of text.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/28444161/106252364-28202380-6251-11eb-934c-d8893c2eaeca.png" width="80%"/> <img src="https://user-images.githubusercontent.com/28444161/106252364-28202380-6251-11eb-934c-d8893c2eaeca.png" width="80%"/>
</p> </p>
## Graph--网络结构组件
### 介绍 ## Graph--Network Structure
Graph组件一键可视化模型的网络结构。用于查看模型属性、节点信息、节点输入输出等,并进行节点搜索,协助开发者们快速分析模型结构与了解数据流向。 ### Introduction
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 ### Demo
共有两种启动方式: There are two methods to launch this component:
- 前端启动Graph: - By the front end:
- 如只需使用Graph,无需添加任何参数,在命令行执行`visualdl`后即可启动。 - If developers only need to use Graph, developers can launch VisualDL (Graph) by executing `visualdl`on the command line.
- 如果同时需使用其他功能,在命令行指定日志文件路径(以`./log`为例),即可启动: - 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 ```shell
visualdl --logdir ./log --port 8080 visualdl --logdir ./log --port 8080
``` ```
- 后端启动Graph: - By the backend:
- 在命令行加入参数`--model`并指定**模型文件**路径(非文件夹路径),即可启动: - Add the parameter `--model` and specify the **model file** path (not the folder path) to launch the panel:
```shell ```shell
visualdl --model ./log/model --port 8080 visualdl --model ./log/model --port 8080
``` ```
*Graph目前只支持可视化网络结构格式的模型文件(如__model__(注意此处为两个下划线'_'))
启动后即可查看网络结构可视化: After the launch, developers can view the network structure:
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84490149-51e20580-acd5-11ea-9663-1f156892c0e0.png" width="80%"/> <img src="https://user-images.githubusercontent.com/48054808/90877274-6548d580-e3d6-11ea-9804-74a1ead47b30.png" width="80%"/>
</p> </p>
### 功能操作说明 ### Functional Instructions
- 一键上传模型 - Upload the model file by one-click
- 支持模型格式:PaddlePaddle、ONNX、Keras、Core ML、Caffe、Caffe2、Darknet、MXNet、ncnn、TensorFlow Lite - Supported model:PaddlePaddle、ONNX、Keras、Core ML、Caffe、Caffe2、Darknet、MXNet、ncnn、TensorFlow Lite
- 实验性支持模型格式:TorchScript、PyTorch、Torch、 ArmNN、BigDL、Chainer、CNTK、Deeplearning4j、MediaPipe、ML.NET、MNN、OpenVINO、Scikit-learn、Tengine、TensorFlow.js、TensorFlow - Experimental supported model:TorchScript、PyTorch、Torch、 ArmNN、BigDL、Chainer、CNTK、Deeplearning4j、MediaPipe、ML.NET、MNN、OpenVINO、Scikit-learn、Tengine、TensorFlow.js、TensorFlow
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487396-44c31780-acd1-11ea-831a-1632e636613d.png" width="80%"/> <img src="https://user-images.githubusercontent.com/48054808/90877449-a80aad80-e3d6-11ea-8016-0a2f3afe6f5e.png" width="80%"/>
</p> </p>
- 支持上下左右任意拖拽模型、放大和缩小模型 - Developers are allowed to drag the model up and down,left and right,zoom in and zoom out.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487568-8784ef80-acd1-11ea-9da1-befedd69b872.GIF" width="80%"/> <img src="https://user-images.githubusercontent.com/48054808/90878058-a097d400-e3d7-11ea-9543-bcef67ace675.gif" width="80%"/>
</p> </p>
- 搜索定位到对应节点 - Search to locate the specific node
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487694-b9965180-acd1-11ea-8214-34f3febc1828.png" width="30%"/> <img src="https://user-images.githubusercontent.com/48054808/90878136-c0c79300-e3d7-11ea-9a14-1c1e809af442.png" width="30%"/>
</p> </p>
- 点击查看模型属性 - Click to view the model properties
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487751-cadf5e00-acd1-11ea-9ce2-4fdfeeea9c5a.png" width="30%"/> <img src="https://user-images.githubusercontent.com/48054808/90878623-5531f580-e3d8-11ea-89cc-1be3500bff66.png" width="30%"/>
</p> </p>
<p align="center"> - Display the model information by selecting corresponded attributes
<img src="https://user-images.githubusercontent.com/48054808/84487759-d03ca880-acd1-11ea-9294-520ef7f9e0b1.png" width="30%"/>
</p>
- 支持选择模型展示的信息
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487829-ee0a0d80-acd1-11ea-8563-6682a15483d9.png" width="23%"/> <img src="https://user-images.githubusercontent.com/48054808/90878712-6ed33d00-e3d8-11ea-85b9-48bf57867d30.png" width="23%"/>
</p> </p>
- 支持以PNG、SVG格式导出文件 - Files can be ex as PNG or SVG format
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487884-ff531a00-acd1-11ea-8b12-5221db78683e.png" width="30%"/> <img src="https://user-images.githubusercontent.com/48054808/90878893-b35ed880-e3d8-11ea-8c22-badee805bfff.png" width="30%"/>
</p> </p>
- 点击节点即可展示对应属性信息 - Click nodes to view attribute information
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487941-13971700-acd2-11ea-937d-42fb524b9ee1.png" width="30%"/> <img src="https://user-images.githubusercontent.com/48054808/90878944-c5407b80-e3d8-11ea-9db2-10e1dd1de5bf.png" width="30%"/>
</p> </p>
- 支持一键更换模型 - Switch the model by one-click
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487998-27db1400-acd2-11ea-83d7-5d75832ef41d.png" width="25%"/> <img src="https://user-images.githubusercontent.com/48054808/90879247-34b66b00-e3d9-11ea-94ef-a26b1ba07dd0.png" width="25%"/>
</p> </p>
## Histogram--直方图组件 ## Histogram--Distribution of Tensors
### 介绍 ### Introduction
Histogram组件以直方图形式展示Tensor(weight、bias、gradient等)数据在训练过程中的变化趋势。深入了解模型各层效果,帮助开发者精准调整模型结构。 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
Histogram 组件的记录接口如下: The interface of the Histogram is shown as follows:
```python ```python
add_histogram(tag, values, step, walltime=None, buckets=10) add_histogram(tag, values, step, walltime=None, buckets=10)
``` ```
接口参数说明如下:
| 参数 | 格式 | 含义 | The interface parameters are described as follows:
| -------- | --------------------- | ------------------------------------------- |
| tag | string | 记录指标的标志,如`train/loss`,不能含有`%` | | parameter | format | meaning |
| values | numpy.ndarray or list | 以ndarray或list格式表示的数据 | | --------- | --------------------- | ------------------------------------------------------------ |
| step | int | 记录的步数 | | tag | string | Record the name of the image data,e.g.train/loss. Notice that the name cannot contain `%` |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 | | values | numpy.ndarray or list | Data is in ndarray or list format, which shape is (N, ) |
| buckets | int | 生成直方图的分段数,默认为10 | | 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 ### Demo
下面展示了使用 Histogram组件记录数据的示例,代码见[Histogram组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/histogram_test.py) 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)
```python ```python
from visualdl import LogWriter from visualdl import LogWriter
...@@ -639,87 +580,91 @@ if __name__ == '__main__': ...@@ -639,87 +580,91 @@ if __name__ == '__main__':
buckets=10) buckets=10)
``` ```
运行上述程序后,在命令行执行 After running the above program, developers can launch the panel by:
```shell ```shell
visualdl --logdir ./log --port 8080 visualdl --logdir ./log --port 8080
``` ```
在浏览器输入`http://127.0.0.1:8080`,即可查看训练参数直方图。 Then, open the browser and enter the address: `http://127.0.0.1:8080`to view the histogram.
### 功能操作说明 ### Functional Instructions
- Developers are allowed to zoom in and download the histogram.
- 支持数据卡片「最大化」、「下载」直方图
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86535351-42d82700-bf12-11ea-89f0-171280e7c526.png" width="60%"/> <img src="https://user-images.githubusercontent.com/48054808/86535351-42d82700-bf12-11ea-89f0-171280e7c526.png" width="60%"/>
</p> </p>
- 可选择Offset或Overlay模式 - Provide two modes: Offset and Overlay.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86535413-c134c900-bf12-11ea-9ad6-f0ad8eafa76f.png" width="30%"/> <img src="https://user-images.githubusercontent.com/48054808/90879332-56175700-e3d9-11ea-87c3-24682191ddd4.png" width="30%"/>
</p> </p>
- Offset模式
- Offset mode
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536435-2b9d3780-bf1a-11ea-9981-92f837d22ae5.png" width="60%"/> <img src="https://user-images.githubusercontent.com/48054808/86536435-2b9d3780-bf1a-11ea-9981-92f837d22ae5.png" width="60%"/>
</p> </p>
- Overlay模式
- Overlay mode
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536458-5ab3a900-bf1a-11ea-985e-05f06c1b762b.png" width="60%"/> <img src="https://user-images.githubusercontent.com/48054808/86536458-5ab3a900-bf1a-11ea-985e-05f06c1b762b.png" width="60%"/>
</p> </p>
- 数据点Hover展示参数值、训练步数、频次 - Display the parameters、training steps and frequency by hovering on specific data points.
- 在第240次训练步数时,权重为-0.0031,且出现的频次是2734次
- In the 240th training step, the weight is -0.0031and the frequency is 2734
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536482-80d94900-bf1a-11ea-9e12-5bea9f382b34.png" width="60%"/> <img src="https://user-images.githubusercontent.com/48054808/86536482-80d94900-bf1a-11ea-9e12-5bea9f382b34.png" width="60%"/>
</p> </p>
- 可搜索卡片标签,展示目标直方图 - Developers can find target histogram by searching corresponded tags.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536503-baaa4f80-bf1a-11ea-80ab-cd988617d018.png" width="30%"/> <img src="https://user-images.githubusercontent.com/48054808/90879724-ebb2e680-e3d9-11ea-9e05-9bc06691ed9c.png" width="85%"/>
</p> </p>
- 可搜索打点数据标签,展示特定数据流 - Search tags to show the histograms generated by corresponded experiments.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536639-b894c080-bf1b-11ea-9ee5-cf815dd4bbd7.png" width="30%"/> <img src="https://user-images.githubusercontent.com/48054808/90879868-26b51a00-e3da-11ea-8c1d-83fb019ec668.png" width="40%"/>
</p> </p>
## PR Curve--PR曲线组件 ## PR Curve
### 介绍 ### Introduction
PR Curve以折线图形式呈现精度与召回率的权衡分析,清晰直观了解模型训练效果,便于分析模型是否达到理想标准。 PR Curve presents precision-recall curves in line charts, describing the tradeoff relationship between precision and recall in order to choose a best threshold.
### 记录接口 ### Record Interface
PR Curve组件的记录接口如下: The interface of the PR Curve is shown as follows:
```python ```python
add_pr_curve(tag, labels, predictions, step=None, num_thresholds=10) add_pr_curve(tag, labels, predictions, step=None, num_thresholds=10)
``` ```
接口参数说明如下: The interface parameters are described as follows:
| 参数 | 格式 | 含义 | | parameter | format | meaning |
| -------------- | --------------------- | ------------------------------------------- | | -------------- | --------------------- | ------------------------------------------- |
| tag | string | 记录指标的标志,如`train/loss`,不能含有`%` | | tag | string | Record the name of the image data,e.g.train/loss. Notice that the name cannot contain `%` |
| labels | numpy.ndarray or list | 以ndarray或list格式表示的实际类别 | | labels | numpy.ndarray or list | Data is in ndarray or list format, which shape should be (N, ) and value should be 0 or 1 |
| predictions | numpy.ndarray or list | 以ndarray或list格式表示的预测类别 | | predictions | numpy.ndarray or list | Prediction data is in ndarray or list format, which shape should be (N, ) and value should in [0, 1] |
| step | int | 记录的步数 | | step | int | Record the training steps |
| num_thresholds | int | 阈值设置的个数,默认为10,最大值为127 | | num_thresholds | int | Set the number of thresholds, default as 10, maximum as 127 |
| weights | float | 用于设置TP/FP/TN/FN在计算precision和recall时的权重 | | weights | float | Set the weights of TN/FN/TP/FP to calculate precision and recall |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 | | walltime | int | Record the time-stamp of the data, and the default is the current time-stamp |
### Demo ### Demo
下面展示了使用 PR Curve 组件记录数据的示例,代码见[PR Curve组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/pr_curve_test.py) The following shows an example of how to use PR Curve component, and script can be found in [PR Curve Demo](../../demo/components/pr_curve_test.py)
```python ```python
from visualdl import LogWriter from visualdl import LogWriter
...@@ -736,88 +681,89 @@ with LogWriter("./log/pr_curve_test/train") as writer: ...@@ -736,88 +681,89 @@ with LogWriter("./log/pr_curve_test/train") as writer:
num_thresholds=5) num_thresholds=5)
``` ```
运行上述程序后,在命令行执行 After running the above program, developers can launch the panel by:
```shell ```shell
visualdl --logdir ./log --port 8080 visualdl --logdir ./log --port 8080
``` ```
接着在浏览器打开`http://127.0.0.1:8080`,即可查看PR Curve Then, open the browser and enter the address`http://127.0.0.1:8080` to view:
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86738774-ee46c000-c067-11ea-90d2-a98aac445cca.png" width="80%"/> <img src="https://user-images.githubusercontent.com/48054808/90879904-37fe2680-e3da-11ea-9369-2513620bf541.png" width="85%"/>
</p> </p>
### 功能操作说明 ### Functional Instrucions
- 支持数据卡片「最大化」、「还原」、「下载」PR曲线 - Developers can zoom in, restore, and download PR Curves
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86740067-f18e7b80-c068-11ea-96bf-52cb7da1f799.png" width="40%"/> <img src="https://user-images.githubusercontent.com/48054808/86740067-f18e7b80-c068-11ea-96bf-52cb7da1f799.png" width="40%"/>
</p> </p>
- 数据点Hover展示详细信息:阈值对应的TP、TN、FP、FN - Developers hover on the specific data point to learn about the detailed information: TP, TN, FP, FN and the corresponded thresholds
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86740477-43370600-c069-11ea-93f0-f4d05445fbab.png" width="50%"/> <img src="https://user-images.githubusercontent.com/48054808/90879971-4e0be700-e3da-11ea-989a-777b977c271d.png" width="50%"/>
</p> </p>
- 可搜索卡片标签,展示目标图表 - The targeted PR Curves can be displayed by searching tags
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86740670-66fa4c00-c069-11ea-9ee3-0a22e2d0dbec.png" width="30%"/> <img src="https://user-images.githubusercontent.com/48054808/90880145-8e6b6500-e3da-11ea-8f06-28248ee2eb84.png" width="80%"/>
</p> </p>
- 可搜索打点数据标签,展示特定数据 - Developers can find specific labels by searching tags or view the all labels
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86740817-809b9380-c069-11ea-9453-6531e3ff5f43.png" width="30%"/> <img src="https://user-images.githubusercontent.com/48054808/90880173-9fb47180-e3da-11ea-8704-34cc55c0a844.png" width="30%"/>
</p> </p>
- 支持查看不同训练步数下的PR曲线 - Developers is able to observe the changes of PR Curves across training steps
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86741057-b04a9b80-c069-11ea-9fef-2dcc16f9cd46.png" width="30%"/> <img src="https://user-images.githubusercontent.com/48054808/90880301-d2f70080-e3da-11ea-97e0-952b389f8010.png" width="30%"/>
</p> </p>
- X轴-时间显示类型有三种衡量尺度 - There are three measurement scales of X axis
- Step:迭代次数
- Walltime:训练绝对时间 1. Step: number of iterations
- Relative:训练时长 2. Walltime: absolute training time
3. Relative: training time
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86741304-db34ef80-c069-11ea-86eb-787b49ed3705.png" width="30%"/> <img src="https://user-images.githubusercontent.com/48054808/90880354-eace8480-e3da-11ea-921f-20f363eb1b1d.png" width="30%"/>
</p> </p>
## ROC Curve--ROC曲线组件 ## ROC Curve
### 介绍 ### Introduction
ROC曲线展示不同阈值下模型指标的变化,同时曲线下的面积(AUC)直观的反应模型表现,辅助开发者掌握模型训练情况并高效进行阈值选择。 ROC Curve shows the performance of a classification model at all classification thresholds; the larger the area under the curve, the better the model performs, aiding developers to evaluate the model performance and choose an appropriate threshold.
### 记录接口 ### Record Interface
ROC Curve组件的记录接口如下: The interface of the PR Curve is shown as follows:
```python ```python
add_roc_curve(tag, labels, predictions, step=None, num_thresholds=10) add_roc_curve(tag, labels, predictions, step=None, num_thresholds=10)
``` ```
接口参数说明如下: The interface parameters are described as follows:
| 参数 | 格式 | 含义 | | parameter | format | meaning |
| -------------- | --------------------- | ------------------------------------------- | | -------------- | --------------------- | ------------------------------------------- |
| tag | string | 记录指标的标志,如`train/loss`,不能含有`%` | | tag | string | Record the name of the image data,e.g.train/loss. Notice that the name cannot contain `%` |
| labels | numpy.ndarray or list | 以ndarray或list格式表示的实际类别 | | values | numpy.ndarray or list | Data is in ndarray or list format, which shape should be (N, ) and value should be 0 or 1 |
| predictions | numpy.ndarray or list | 以ndarray或list格式表示的预测类别 | | predictions | numpy.ndarray or list | Prediction data is in ndarray or list format, which shape should be (N, ) and value should in [0, 1] |
| step | int | 记录的步数 | | step | int | Record the training steps |
| num_thresholds | int | 阈值设置的个数,默认为10,最大值为127 | | num_thresholds | int | Set the number of thresholds, default as 10, maximum as 127 |
| weights | float | 用于设置TP/FP/TN/FN在计算precision和recall时的权重 | | weights | float | Set the weights of TN/FN/TP/FP to calculate precision and recall |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 | | walltime | int | Record the time-stamp of the data, and the default is the current time-stamp |
### Demo ### Demo
下面展示了使用 ROC Curve 组件记录数据的示例,代码见[ROC Curve组件](https://github.com/YixinKristy/VisualDL/blob/develop/demo/components/roc_curve_test.py) The following shows an example of how to use ROC curve component, and script can be found in [ROC Curve Demo](../../demo/components/roc_curve_test.py)
```python ```python
from visualdl import LogWriter from visualdl import LogWriter
...@@ -832,50 +778,51 @@ with LogWriter("./log/roc_curve_test/train") as writer: ...@@ -832,50 +778,51 @@ with LogWriter("./log/roc_curve_test/train") as writer:
predictions=predictions, predictions=predictions,
step=step, step=step,
num_thresholds=5) num_thresholds=5)
``` ```
运行上述程序后,在命令行执行 After running the above program, developers can launch the panel by:
```shell ```shell
visualdl --logdir ./log --port 8080 visualdl --logdir ./log --port 8080
``` ```
接着在浏览器打开`http://127.0.0.1:8080`,即可查看ROC Curve Then, open the browser and enter the address`http://127.0.0.1:8080` to view:
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103344081-8928d000-4ac8-11eb-84d0-28f249886172.gif" width="80%"/> <img src="https://user-images.githubusercontent.com/48054808/103344081-8928d000-4ac8-11eb-84d0-28f249886172.gif" width="85%"/>
</p> </p>
*Note:ROC前端页面使用和PR相同,请参考上述PR Curve的使用说明。 *Note: the use of ROC Curve in the frontend is the same as that of PR Curve, please refer to the instructions in PR Curve section if needed.
## High Dimensional--数据降维组件 ## High Dimensional--Data Dimensionality Reduction
### 介绍 ### Introduction
High Dimensional 组件将高维数据进行降维展示,用于深入分析高维数据间的关系。目前支持以下三种降维算法: 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. Three dimensionality reduction algorithms are supported:
- PCA : Principle Component Analysis 主成分分析 - PCA : Principle Component Analysis
- t-SNE : t-distributed stochastic neighbor embedding t-分布式随机领域嵌入 - t-SNE : t-distributed Stochastic Neighbor Embedding
- umap: uniform manifold approximation and projection for dimension reduction 流形学习降维算法 - umap: Uniform Manifold Approximation and Projection
### 记录接口 ### Record Interface
High Dimensional 组件的记录接口如下: The interface of the High Dimensional is shown as follows:
```python ```python
add_embeddings(tag, labels, hot_vectors, walltime=None) add_embeddings(tag, labels, hot_vectors, walltime=None)
``` ```
接口参数说明如下: The interface parameters are described as follows:
| 参数 | 格式 | 含义 | | parameter | format | meaning |
| ----------- | ------------------- | ---------------------------------------------------- | | ----------- | ------------------- | ------------------------------------------------------------ |
| tag | string | 记录指标的标志,如`default`,不能含有`%` | | tag | string | Record the name of the high dimensional data, e.g.`default`. Notice that the name cannot contain `%` |
| labels | numpy.array 或 list | 一维数组表示的标签,代表hot_vectors的标签,如果有多个维度的labels需要使用二维数组,其中每个元素为某维度下的一维标签数组 | | labels | numpy.array or list | Represents the label of hot_vectors. The shape of `labels` should be (N, ) if only one dimension, and should be (M, N) if dimension of `labels` more than one, where each element is a one-dimensional label array. Each element is string type. |
| hot_vectors | numpy.array or list | 与labels一一对应,每个元素可以看作是某个标签的特征 | | hot_vectors | numpy.array or list | Each element can be seen as a feature of the tag corresponding to the label. |
| labels_meta | numpy.array or list | labels的标签,与labels一一对应,不指定则使用默认值`__metadata__`,当labels为一维数组时无需指定 | | labels_meta | numpy.array or list | The labels of parameter `labels` correspond to `labels` one-to-one. If not specified, the default value `__metadata__` will be used. When parameter `labels` is a one-dimensional array, there is no need to specify this parameter |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 | | walltime | int | Record the time stamp of the data, the default is the current time stamp. |
### Demo ### Demo
下面展示了使用 High Dimensional 组件记录数据的示例,代码见[High Dimensional组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/high_dimensional_test.py) 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)
```python ```python
from visualdl import LogWriter from visualdl import LogWriter
...@@ -889,90 +836,79 @@ if __name__ == '__main__': ...@@ -889,90 +836,79 @@ if __name__ == '__main__':
[1.3913371800587777, 1.4684674577930312, 1.5214136352476377]] [1.3913371800587777, 1.4684674577930312, 1.5214136352476377]]
labels = ["label_1", "label_2", "label_3", "label_4", "label_5"] labels = ["label_1", "label_2", "label_3", "label_4", "label_5"]
# 初始化一个记录器 # initialize a recorder
with LogWriter(logdir="./log/high_dimensional_test/train") as writer: with LogWriter(logdir="./log/high_dimensional_test/train") as writer:
# 将一组labels和对应的hot_vectors传入记录器进行记录 # recorde a set of labels and corresponding hot_vectors to the recorder
writer.add_embeddings(tag='default', writer.add_embeddings(tag='default',
labels=labels, labels=labels,
hot_vectors=hot_vectors) hot_vectors=hot_vectors)
"""
# 也可以同时提供多个label,此时`labels`为二维数组,且需要提供`labels_meta`以供前端页面选择展示不同label.
labels = [["label_a_1", "label_a_2", "label_a_3", "label_a_4", "label_a_5"],
["label_b_1", "label_b_2", "label_b_3", "label_b_4", "label_b_5"]]
# labels_meta需要和labels一一对应
labels_meta = ["label_a", "label_b"]
with LogWriter(logdir="./log/high_dimensional_test/train") as writer:
writer.add_embeddings(tag='default',
labels=labels,
labels_meta=labels_meta,
hot_vectors=hot_vectors)
"""
``` ```
运行上述程序后,在命令行执行 After running the above program, developers can launch the panel by:
```shell ```shell
visualdl --logdir ./log --port 8080 visualdl --logdir ./log --port 8080
``` ```
接着在浏览器打开`http://127.0.0.1:8080`,即可查看降维后的可视化数据。 Then, open the browser and enter the address`http://127.0.0.1:8080` to view:
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103188111-1b32ac00-4902-11eb-914e-c2368bdb8373.gif" width="85%"/> <img src="https://user-images.githubusercontent.com/48054808/103188111-1b32ac00-4902-11eb-914e-c2368bdb8373.gif" width="85%"/>
</p> </p>
### 功能操作说明 ### Functional Instrucions
* 支持选择特定实验数据进行展示,且支持根据所选择的数据标签进行展示 * Developers are allowed to select specific runs of data or certain labels of data to display
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103191809-4e306c00-4911-11eb-853f-e143ef86e182.png" width="30%"/> <img src="https://user-images.githubusercontent.com/48054808/103191809-4e306c00-4911-11eb-853f-e143ef86e182.png" width="30%"/>
</p> </p>
* 降维方式--TSNE * TSNE
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103192762-cea49c00-4914-11eb-896c-070b0bf0e2ea.png" width="27%"/> <img src="https://user-images.githubusercontent.com/48054808/103192762-cea49c00-4914-11eb-896c-070b0bf0e2ea.png" width="27%"/>
</p> </p>
* 降维方式--PCA * PCA
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103192341-47a2f400-4913-11eb-9995-fdc0acadbdc9.png" width="27%"/> <img src="https://user-images.githubusercontent.com/48054808/103192341-47a2f400-4913-11eb-9995-fdc0acadbdc9.png" width="27%"/>
</p> </p>
* 降维方式--UMAP * UMAP
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103192766-d2d0b980-4914-11eb-871e-e4b31542c5e9.png" width="27%"/> <img src="https://user-images.githubusercontent.com/48054808/103192766-d2d0b980-4914-11eb-871e-e4b31542c5e9.png" width="27%"/>
</p> </p>
## VDL.service ## VDL.service
### 简介 ### Introduction
VisualDL可视化结果保存服务,以链接形式将可视化结果保存下来,方便用户快速、便捷的进行托管与分享。 VDL.service enables developers to easily save, track and share visualization results with anyone for free.
### 使用步骤 ### Usage Steps
1. 确保VisualDL已升级到最新版本,如未升级,请使用以下命令进行升级 1. Make sure that your get the lastest version of VisualDL, if not, please update by:
``` ```
pip install visualdl --upgrade pip install visualdl --upgrade
``` ```
2. 上传需保存/分享的日志/模型文件 2. Upload log/model to save, track and share the visualization results.
``` ```
visualdl service upload --logdir ./log \ visualdl service upload --logdir ./log \
--model ./__model__ --model ./__model__
``` ```
3. VDL.service将返回一个URL链接,复制粘贴链接至浏览器中即可查看可视化结果 3. An unique URL will be given. Then you can view the visualization results by simply copying and pasting the URL to the browser.
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93733769-5ccc0080-fc09-11ea-88c0-6f17c04ebdce.png" width="100%"/> <img src="https://user-images.githubusercontent.com/48054808/93733769-5ccc0080-fc09-11ea-88c0-6f17c04ebdce.png" width="100%"/>
</p> </p>
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93733790-69e8ef80-fc09-11ea-9256-68a88072f5d2.png" width="100%"/> <img src="https://user-images.githubusercontent.com/48054808/93734496-057b5f80-fc0c-11ea-9b52-229ff8847bc0.png" width="100%"/>
</p> </p>
[**English**](./README.md)
# VisualDL 使用指南
### 概述
VisualDL 是一个面向深度学习任务设计的可视化工具。VisualDL 利用了丰富的图表来展示数据,用户可以更直观、清晰地查看数据的特征与变化趋势,有助于分析数据、及时发现错误,进而改进神经网络模型的设计。
目前,VisualDL 支持 scalar, image, audio,graph, histogram, pr curve, ROC curve, high dimensional 七个组件,项目正处于高速迭代中,敬请期待新组件的加入。
| 组件名称 | 展示图表 | 作用 |
| :----------------------------------------------------------: | :--------: | :----------------------------------------------------------- |
| [ Scalar](#Scalar--标量组件) | 折线图 | 动态展示损失函数值、准确率等标量数据 |
| [Image](#Image--图片可视化组件) | 图片可视化 | 显示图片,可显示输入图片和处理后的结果,便于查看中间过程的变化 |
| [Audio](#Audio--音频播放组件) | 音频可视化 | 播放训练过程中的音频数据,监控语音识别与合成等任务的训练过程 |
| [Text](#Text--文本组件) | 文本可视化 | 展示文本任务任意阶段的数据输出,对比不同阶段的文本变化,便于深入了解训练过程及效果。 |
| [Graph](#Graph--网络结构组件) | 网络结构 | 展示网络结构、节点属性及数据流向,辅助学习、优化网络结构 |
| [Histogram](#Histogram--直方图组件) | 直方图 | 展示训练过程中权重、梯度等张量的分布 |
| [PR Curve](#PR-Curve--PR曲线组件) | 折线图 | 权衡精度与召回率之间的平衡关系 |
| [ROC Curve](#ROC-Curve--ROC曲线组件) | 折线图 | 展示不同阈值下的模型表现 |
| [High Dimensional](#High-Dimensional--数据降维组件) | 数据降维 | 将高维数据映射到 2D/3D 空间来可视化嵌入,便于观察不同数据的相关性 |
同时,VisualDL提供可视化结果保存服务,通过 [VDL.service](#vdlservice) 生成链接,保存并分享可视化结果
## Scalar--标量组件
### 介绍
Scalar 组件的输入数据类型为标量,该组件的作用是将训练参数以折线图形式呈现。将损失函数值、准确率等标量数据作为参数传入 scalar 组件,即可画出折线图,便于观察变化趋势。
### 记录接口
Scalar 组件的记录接口如下:
```python
add_scalar(tag, value, step, walltime=None)
```
接口参数说明如下:
| 参数 | 格式 | 含义 |
| -------- | ------ | ------------------------------------------- |
| tag | string | 记录指标的标志,如`train/loss`,不能含有`%` |
| value | float | 要记录的数据值,不能为None |
| step | int | 记录的标量数据的步数,前端将抽取若干step对应的数据进行展示(VisualDL使用的采样算法为蓄水池采样,可参考[VisualDL采样算法](../faq_CN.md/#VisualDL的采样规则是什么)) |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 |
*注意tag的使用规则为:
1. 第一个`/`前的为父tag,并作为一栏图片的tag
2. 第一个`/`后的为子tag,子tag的对应图片将显示在父tag下,同一个父tag而不同子tag的数据将展示在一栏,但不是一张图中
3. 可以使用多次`/`,但一栏图片的tag依旧为第一个`/`前的tag
具体使用参见以下三个例子:
- 创建train为父tag,acc和loss为子tag:`train/acc``train/loss`,即创建了tag为train的图片栏,包含acc和loss两张图表:
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84653342-d6d05780-af3f-11ea-8979-8da039ae7201.JPG" width="100%"/>
</p>
- 创建train为父tag,test/acc和test/loss为子tag:`train/test/acc``train/test/loss`,即创建了tag为train的图片栏,包含test/acc和test/loss两张图表:
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84644066-3bd08100-af31-11ea-8eb5-c4a4cab351ed.png" width="100%"/>
</p>
- 创建两个父tag:`acc``loss`,即创建了tag分别为acc和loss的两个图表栏::
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84644323-99fd6400-af31-11ea-9855-eca7f7b01810.png" width="100%"/>
</p>
### Demo
- 基础使用
下面展示了使用 Scalar 组件记录数据的示例,代码见[Scalar组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/scalar_test.py)
```python
from visualdl import LogWriter
if __name__ == '__main__':
value = [i/1000.0 for i in range(1000)]
# 初始化一个记录器
with LogWriter(logdir="./log/scalar_test/train") as writer:
for step in range(1000):
# 向记录器添加一个tag为`acc`的数据
writer.add_scalar(tag="acc", step=step, value=value[step])
# 向记录器添加一个tag为`loss`的数据
writer.add_scalar(tag="loss", step=step, value=1/(value[step] + 1))
```
运行上述程序后,在命令行执行
```shell
visualdl --logdir ./log --port 8080
```
接着在浏览器打开`http://127.0.0.1:8080`,即可查看以下折线图。
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93732057-36ef2d80-fc02-11ea-9dac-b8fdce194d09.png" width="100%"/>
</p>
- 多组实验对比
下面展示了使用Scalar组件实现多组实验对比
多组实验对比的实现分为两步:
1. 创建子日志文件储存每组实验的参数数据
2. 将数据写入scalar组件时,**使用相同的tag**,即可实现对比**不同实验****同一类型参数**,这里注意想展示的日志文件必须放在不同的目录下,默认一个目录中只有一个日志文件有效且被展示
```python
from visualdl import LogWriter
if __name__ == '__main__':
value = [i/1000.0 for i in range(1000)]
# 步骤一:创建父文件夹:log,子文件夹:scalar_test
with LogWriter(logdir="./log/scalar_test") as writer:
for step in range(1000):
# 步骤二:向记录器添加一个tag为`train/acc`的数据
writer.add_scalar(tag="train/acc", step=step, value=value[step])
# 步骤二:向记录器添加一个tag为`train/loss`的数据
writer.add_scalar(tag="train/loss", step=step, value=1/(value[step] + 1))
# 步骤一:创建第二个子文件夹:scalar_test2
value = [i/500.0 for i in range(1000)]
with LogWriter(logdir="./log/scalar_test2") as writer:
for step in range(1000):
# 步骤二:在同样名为`train/acc`下添加scalar_test2的accuracy的数据
writer.add_scalar(tag="train/acc", step=step, value=value[step])
# 步骤二:在同样名为`train/loss`下添加scalar_test2的loss的数据
writer.add_scalar(tag="train/loss", step=step, value=1/(value[step] + 1))
```
运行上述程序后,在命令行执行
```shell
visualdl --logdir ./log --port 8080
```
接着在浏览器打开`http://127.0.0.1:8080`,即可查看以下折线图,观察scalar_test和scalar_test2的accuracy和loss的对比。
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84644158-5efb3080-af31-11ea-8e64-bbe4078425f4.png" width="100%"/>
</p>
可以看出,不同实验(由路径决定)的数据在不同的图中展示,相同tag的数据在同一张图上展示,以便对比
*多组实验对比的应用案例可以参考AI Studio项目:[VisualDL 2.0--眼疾识别训练可视化](https://aistudio.baidu.com/aistudio/projectdetail/502834)
### 功能操作说明
* 支持数据卡片「最大化」、「还原」、「坐标系转化」(y轴对数坐标)、「下载」折线图
<p align="center">
<img src="https://visualdl.bj.bcebos.com/images/scalar-icon.png" width="55%"/>
</p>
* 数据点Hover展示详细信息
<p align="center">
<img src="https://visualdl.bj.bcebos.com/images/scalar-tooltip.png" width="60%"/>
</p>
* 可搜索卡片标签,展示目标图像
<p align="center">
<img src="https://visualdl.bj.bcebos.com/images/scalar-searchlabel.png" width="90%"/>
</p>
* 可搜索打点数据标签,展示特定数据
<p align="center">
<img src="https://visualdl.bj.bcebos.com/images/scalar-searchstream.png" width="40%"/>
</p>
* 选择显示最值,展示最大最小值以及对应的训练步数
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93732336-65213d00-fc03-11ea-96f4-cc6497094a06.png" width="20%"/>
</p>
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93732424-d8c34a00-fc03-11ea-8b7b-0a728274f50f.png" width="60%"/>
</p>
* 选择仅显示平滑后的数据
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93732485-263fb700-fc04-11ea-9edb-40cb8676aad0.png" width="25%"/>
</p>
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93732514-4cfded80-fc04-11ea-99c9-9053f9945c8b.png" width="60%"/>
</p>
* X轴有三种衡量尺度
1. Step:迭代次数
2. Walltime:训练绝对时间
3. Relative:训练时长
<p align="center">
<img src="https://visualdl.bj.bcebos.com/images/x-axis.png" width="40%"/>
</p>
* 可调整曲线平滑度,以便更好的展现参数整体的变化趋势
<p align="center">
<img src="https://visualdl.bj.bcebos.com/images/scalar-smooth.png" width="37%"/>
</p>
## Image--图片可视化组件
### 介绍
Image 组件用于显示图片数据随训练的变化。在模型训练过程中,将图片数据传入 Image 组件,就可在 VisualDL 的前端网页查看相应图片。
### 记录接口
Image 组件的记录接口如下:
```python
add_image(tag, img, step, walltime=None, dataformats="HWC")
```
接口参数说明如下:
| 参数 | 格式 | 含义 |
| -------- | ------------- | ------------------------------------------- |
| tag | string | 记录指标的标志,如`train/loss`,不能含有`%` |
| img | numpy.ndarray | 以ndarray格式表示的图片,默认`HWC`格式维度为[h, w, c],其中h和w代表图像的高度和宽度,c代表图像的通道数,可以为1、3、4,图像数据的浮点型数值会被归一化到[0, 1]。注意图片数据不能为None |
| step | int | 记录的图片数据步数 |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 |
| dataformats| string | 传入的图片格式,包括`NCHW``NHWC``HWC``CHW``HW`,默认为`HWC`,在存储时会转化成`HWC`格式后继续存储|
### Demo
下面展示了使用 Image 组件记录数据的示例,代码文件请见[Image组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/image_test.py)
```python
import numpy as np
from PIL import Image
from visualdl import LogWriter
def random_crop(img):
"""获取图片的随机 100x100 分片
"""
img = Image.open(img)
w, h = img.size
random_w = np.random.randint(0, w - 100)
random_h = np.random.randint(0, h - 100)
# 生成HWC格式的图片
r = img.crop((random_w, random_h, random_w + 100, random_h + 100))
return np.asarray(r)
if __name__ == '__main__':
# 初始化一个记录器
with LogWriter(logdir="./log/image_test/train") as writer:
for step in range(6):
# 添加一个图片数据
writer.add_image(tag="eye",
img=random_crop("../../docs/images/eye.jpg"),
step=step)
```
运行上述程序后,在命令行执行
```shell
visualdl --logdir ./log --port 8080
```
在浏览器输入`http://127.0.0.1:8080`,即可查看图片数据。
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/82397685-86babe00-9a83-11ea-870e-502f313bdc7c.png" width="90%"/>
</p>
### 功能操作说明
- 可搜索图片标签显示对应图片数据
<p align="center">
<img src="https://visualdl.bj.bcebos.com/images/image-search.png" width="90%"/>
</p>
- 支持滑动Step/迭代次数查看不同迭代次数下的图片数据
<p align="center">
<img src="https://visualdl.bj.bcebos.com/images/image-eye.gif" width="60%"/>
</p>
### 添加图片矩阵
除使用add_image记录一张图片之外,还可以使用add_image_matrix一次添加多张图片并生成一张图片矩阵,接口及参数说明如下:
add_image_matrix的记录接口如下:
```python
add_image_matrix(tag, imgs, step, rows=-1, scale=1, walltime=None, dataformats="HWC")
```
接口参数说明如下:
| 参数 | 格式 | 含义 |
| -------- | ------------- | ------------------------------------------- |
| tag | string | 记录指标的标志,如`train/loss`,不能含有`%` |
| imgs | numpy.ndarray | 以ndarray格式表示的多张图片,第一维为图片的数量,其他维度表示一张图片,根据其格式具有不同的维度,默认`HWC`格式维度为[h, w, c]其中c可以为1、3、4,注意图片数据不能为None |
| step | int | 记录的图片矩阵的步数 |
| rows | int | 生成图片矩阵的行数,默认值为-1,表示尽量把传入的图片组合成行列数相近的形式,否则将自动将图片排列按照rows进行重新组织 |
| scale | int | 图片放大比例,默认为1,放大缩小图片可能造成图片像素缺失 |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 |
| dataformats| string | 传入的图片格式,包括`NCHW``NHWC``HWC``HW`,默认为`HWC`,在存储时会转化成`HWC`格式后继续存储|
**PS:当给定的子图像数量不足时,默认将用空白图像填充,以保证生成的图形为完整矩形**
#### Demo
下面展示了使用 Image 组件合成并记录多张图片数据的示例,代码文件请见[Image组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/image_matrix_test.py)
```python
import numpy as np
from PIL import Image
from visualdl import LogWriter
if __name__ == '__main__':
imgs = []
for index in range(6):
imgs.append(np.asarray(Image.open("../../docs/images/images_matrix/%s.jpg" % str((index)))))
with LogWriter(logdir='./log/image_matrix_test/train') as writer:
# 使用add_image记录单张图片
writer.add_image(tag='detection', step=0, img=imgs[0])
# 合成长宽尽量接近的图形矩阵,本例生成3X2的矩阵
writer.add_image_matrix(tag='detection', step=1, imgs=imgs, rows=-1)
# 合成长为1的图形矩阵,本例生成1x6的矩阵
writer.add_image_matrix(tag='detection', step=2, imgs=imgs, rows=1)
# 合成长为2的图形矩阵,本例生成2X3的矩阵
writer.add_image_matrix(tag='detection', step=3, imgs=imgs, rows=2)
# 合成长为3的图形矩阵,本例生成3X2的矩阵
writer.add_image_matrix(tag='detection', step=4, imgs=imgs, rows=3)
# 合成长为4的图形矩阵,本例生成4X2的矩阵,自动补充子图像填充第四行
writer.add_image_matrix(tag='detection', step=5, imgs=imgs, rows=4)
```
运行上述程序后,在命令行执行
```shell
visualdl --logdir ./log --port 8080
```
在浏览器输入`http://127.0.0.1:8080`,即可查看图片数据。
<p align="center">
<img src="https://user-images.githubusercontent.com/28444161/106742199-aae11e00-6657-11eb-827a-c785f9ff336e.png" width="40%"/>
<img src="https://user-images.githubusercontent.com/28444161/106742248-c0eede80-6657-11eb-9c9e-3e858ae6562d.png" width="40%"/>
</p>
## Audio--音频播放组件
### 介绍
Audio组件实时查看训练过程中的音频数据,监控语音识别与合成等任务的训练过程。
### 记录接口
Audio 组件的记录接口如下:
```python
add_audio(tag, audio_array, step, sample_rate)
```
接口参数说明如下:
| 参数 | 格式 | 含义 |
| -------- | ------------- | ------------------------------------------- |
| tag | string | 记录指标的标志,如`audio_tag`,不能含有`%` |
| audio_arry | numpy.ndarray | 以ndarray格式表示的音频,其元素为float值,范围应归一化到[-1, 1] |
| step | int | 记录的音频数据步数 |
| sample_rate | int | 采样率,默认采样率为8000,**注意正确填写对应音频的采样率** |
### Demo
下面展示了使用 Audio 组件记录数据的示例,代码文件请见[Audio组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/audio_test.py)
```python
from visualdl import LogWriter
from scipy.io import wavfile
if __name__ == '__main__':
with LogWriter(logdir="./log/audio_test/train") as writer:
sample_rate, audio_data = wavfile.read('./test.wav')
writer.add_audio(tag="audio_tag",
audio_array=audio_data,
step=0,
sample_rate=sample_rate)
```
运行上述程序后,在命令行执行
```shell
visualdl --logdir ./log --port 8080
```
在浏览器输入`http://127.0.0.1:8080`,即可查看音频数据。
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/87659138-b4746880-c78f-11ea-965b-c33804e7c296.png" width="90%"/>
</p>
### 功能操作说明
- 可搜索音频标签显示对应音频数据
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/87661431-29956d00-c793-11ea-833b-172d8fc1b221.png" width="80%"/>
</p>
- 支持滑动Step/迭代次数查看不同迭代次数下的音频数据
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/87661089-a07e3600-c792-11ea-8740-cbe99a64d830.png" width="40%"/>
</p>
- 支持播放/暂停音频数据
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/87661130-b3910600-c792-11ea-9f9f-2ae66132e9de.png" width="40%"/>
</p>
- 支持音量调节
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/87661497-49c52c00-c793-11ea-9eeb-471543cd2a0b.png" width="40%"/>
</p>
- 支持音频下载
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/87661166-c277b880-c792-11ea-8ad7-5c60bb08379b.png" width="40%"/>
</p>
## Text--文本组件
### 介绍
Text展示文本任务任意阶段的数据输出,对比不同阶段的文本变化,便于深入了解训练过程及效果。
### 记录接口
Text组件的记录接口如下:
```python
add_text(tag, text_string, step=None, walltime=None)
```
接口参数说明如下:
| 参数 | 格式 | 含义 |
| -------------- | --------------------- | ------------------------------------------- |
| tag | string | 记录指标的标志,如`train/loss`,不能含有`%` |
| text_string | string | 文本字符串 |
| step | int | 记录的文本步数 |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 |
### Demo
下面展示了使用 Text 组件记录数据的示例,代码见[Text组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/text_test.py)
```python
from visualdl import LogWriter
if __name__ == '__main__':
texts = [
'上联: 众 佛 群 灵 光 圣 地 下联: 众 生 一 念 证 菩 提',
'上联: 乡 愁 何 处 解 下联: 故 事 几 时 休',
'上联: 清 池 荷 试 墨 下联: 碧 水 柳 含 情',
'上联: 既 近 浅 流 安 笔 砚 下联: 欲 将 直 气 定 乾 坤',
'上联: 日 丽 萱 闱 祝 无 量 寿 下联: 月 明 桂 殿 祝 有 余 龄',
'上联: 一 地 残 红 风 拾 起 下联: 半 窗 疏 影 月 窥 来'
]
with LogWriter(logdir="./log/text_test/train") as writer:
for step in range(len(texts)):
writer.add_text(tag="output", step=step, text_string=texts[step])
```
运行上述程序后,在命令行执行
```shell
visualdl --logdir ./log --port 8080
```
接着在浏览器打开`http://127.0.0.1:8080`,即可查看Text
<p align="center">
<img src="https://user-images.githubusercontent.com/28444161/106248340-cdd09400-624b-11eb-8ea9-5a07a239c365.png" width="95%"/>
</p>
### 功能操作说明
- 可搜索文本标签显示对应文本数据
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536503-baaa4f80-bf1a-11ea-80ab-cd988617d018.png" width="40%"/>
</p>
- 可搜索数据流标签显示对应数据流数据
<p align="center">
<img src="https://user-images.githubusercontent.com/28444161/106256983-f4e09300-6256-11eb-9acc-a24a2ac9b70c.png" width="40%"/>
</p>
- 可折叠标签
<p align="center">
<img src="https://user-images.githubusercontent.com/28444161/106252364-28202380-6251-11eb-934c-d8893c2eaeca.png" width="80%"/>
</p>
## Graph--网络结构组件
### 介绍
Graph组件一键可视化模型的网络结构。用于查看模型属性、节点信息、节点输入输出等,并进行节点搜索,协助开发者们快速分析模型结构与了解数据流向。
### Demo
共有两种启动方式:
- 前端启动Graph:
- 如只需使用Graph,无需添加任何参数,在命令行执行`visualdl`后即可启动。
- 如果同时需使用其他功能,在命令行指定日志文件路径(以`./log`为例),即可启动:
```shell
visualdl --logdir ./log --port 8080
```
- 后端启动Graph:
- 在命令行加入参数`--model`并指定**模型文件**路径(非文件夹路径),即可启动:
```shell
visualdl --model ./log/model --port 8080
```
*Graph目前只支持可视化网络结构格式的模型文件(如__model__(注意此处为两个下划线'_'))
启动后即可查看网络结构可视化:
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84490149-51e20580-acd5-11ea-9663-1f156892c0e0.png" width="80%"/>
</p>
### 功能操作说明
- 一键上传模型
- 支持模型格式:PaddlePaddle、ONNX、Keras、Core ML、Caffe、Caffe2、Darknet、MXNet、ncnn、TensorFlow Lite
- 实验性支持模型格式:TorchScript、PyTorch、Torch、 ArmNN、BigDL、Chainer、CNTK、Deeplearning4j、MediaPipe、ML.NET、MNN、OpenVINO、Scikit-learn、Tengine、TensorFlow.js、TensorFlow
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487396-44c31780-acd1-11ea-831a-1632e636613d.png" width="80%"/>
</p>
- 支持上下左右任意拖拽模型、放大和缩小模型
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487568-8784ef80-acd1-11ea-9da1-befedd69b872.GIF" width="80%"/>
</p>
- 搜索定位到对应节点
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487694-b9965180-acd1-11ea-8214-34f3febc1828.png" width="30%"/>
</p>
- 点击查看模型属性
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487751-cadf5e00-acd1-11ea-9ce2-4fdfeeea9c5a.png" width="30%"/>
</p>
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487759-d03ca880-acd1-11ea-9294-520ef7f9e0b1.png" width="30%"/>
</p>
- 支持选择模型展示的信息
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487829-ee0a0d80-acd1-11ea-8563-6682a15483d9.png" width="23%"/>
</p>
- 支持以PNG、SVG格式导出文件
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487884-ff531a00-acd1-11ea-8b12-5221db78683e.png" width="30%"/>
</p>
- 点击节点即可展示对应属性信息
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487941-13971700-acd2-11ea-937d-42fb524b9ee1.png" width="30%"/>
</p>
- 支持一键更换模型
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/84487998-27db1400-acd2-11ea-83d7-5d75832ef41d.png" width="25%"/>
</p>
## Histogram--直方图组件
### 介绍
Histogram组件以直方图形式展示Tensor(weight、bias、gradient等)数据在训练过程中的变化趋势。深入了解模型各层效果,帮助开发者精准调整模型结构。
### 记录接口
Histogram 组件的记录接口如下:
```python
add_histogram(tag, values, step, walltime=None, buckets=10)
```
接口参数说明如下:
| 参数 | 格式 | 含义 |
| -------- | --------------------- | ------------------------------------------- |
| tag | string | 记录指标的标志,如`train/loss`,不能含有`%` |
| values | numpy.ndarray or list | 以ndarray或list格式表示的数据,其维度为(N, ) |
| step | int | 记录的直方图步数 |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 |
| buckets | int | 生成直方图的分段数,默认为10 |
### Demo
下面展示了使用 Histogram组件记录数据的示例,代码见[Histogram组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/histogram_test.py)
```python
from visualdl import LogWriter
import numpy as np
if __name__ == '__main__':
values = np.arange(0, 1000)
with LogWriter(logdir="./log/histogram_test/train") as writer:
for index in range(1, 101):
interval_start = 1 + 2 * index / 100.0
interval_end = 6 - 2 * index / 100.0
data = np.random.uniform(interval_start, interval_end, size=(10000))
writer.add_histogram(tag='default tag',
values=data,
step=index,
buckets=10)
```
运行上述程序后,在命令行执行
```shell
visualdl --logdir ./log --port 8080
```
在浏览器输入`http://127.0.0.1:8080`,即可查看训练参数直方图。
### 功能操作说明
- 支持数据卡片「最大化」、「下载」直方图
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86535351-42d82700-bf12-11ea-89f0-171280e7c526.png" width="60%"/>
</p>
- 可选择Offset或Overlay模式
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86535413-c134c900-bf12-11ea-9ad6-f0ad8eafa76f.png" width="30%"/>
</p>
- Offset模式
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536435-2b9d3780-bf1a-11ea-9981-92f837d22ae5.png" width="60%"/>
</p>
- Overlay模式
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536458-5ab3a900-bf1a-11ea-985e-05f06c1b762b.png" width="60%"/>
</p>
- 数据点Hover展示参数值、训练步数、频次
- 在第240次训练步数时,权重为-0.0031,且出现的频次是2734次
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536482-80d94900-bf1a-11ea-9e12-5bea9f382b34.png" width="60%"/>
</p>
- 可搜索卡片标签,展示目标直方图
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536503-baaa4f80-bf1a-11ea-80ab-cd988617d018.png" width="30%"/>
</p>
- 可搜索打点数据标签,展示特定数据流
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536639-b894c080-bf1b-11ea-9ee5-cf815dd4bbd7.png" width="30%"/>
</p>
## PR Curve--PR曲线组件
### 介绍
PR Curve以折线图形式呈现精度与召回率的权衡分析,清晰直观了解模型训练效果,便于分析模型是否达到理想标准。
### 记录接口
PR Curve组件的记录接口如下:
```python
add_pr_curve(tag, labels, predictions, step=None, num_thresholds=10)
```
接口参数说明如下:
| 参数 | 格式 | 含义 |
| -------------- | --------------------- | ------------------------------------------- |
| tag | string | 记录指标的标志,如`train/loss`,不能含有`%` |
| labels | numpy.ndarray or list | 以ndarray或list格式表示的实际类别,维度为(N, ),值为0或1 |
| predictions | numpy.ndarray or list | 以ndarray或list格式表示的预测类别,维度为(N, ),值的范围应该在[0, 1] |
| step | int | 记录的pr curve曲线步数 |
| num_thresholds | int | 阈值设置的个数,默认为10,最大值为127 |
| weights | float | 用于设置TP/FP/TN/FN在计算precision和recall时的权重 |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 |
### Demo
下面展示了使用 PR Curve 组件记录数据的示例,代码见[PR Curve组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/pr_curve_test.py)
```python
from visualdl import LogWriter
import numpy as np
# 生成一个日志记录器
with LogWriter("./log/pr_curve_test/train") as writer:
for step in range(3):
labels = np.random.randint(2, size=100)
predictions = np.random.rand(100)
# 添加一条pr curve曲线数据
writer.add_pr_curve(tag='pr_curve',
labels=labels,
predictions=predictions,
step=step,
num_thresholds=5)
```
运行上述程序后,在命令行执行
```shell
visualdl --logdir ./log --port 8080
```
接着在浏览器打开`http://127.0.0.1:8080`,即可查看PR Curve
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86738774-ee46c000-c067-11ea-90d2-a98aac445cca.png" width="80%"/>
</p>
### 功能操作说明
- 支持数据卡片「最大化」、「还原」、「下载」PR曲线
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86740067-f18e7b80-c068-11ea-96bf-52cb7da1f799.png" width="40%"/>
</p>
- 数据点Hover展示详细信息:阈值对应的TP、TN、FP、FN
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86740477-43370600-c069-11ea-93f0-f4d05445fbab.png" width="50%"/>
</p>
- 可搜索卡片标签,展示目标图表
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86740670-66fa4c00-c069-11ea-9ee3-0a22e2d0dbec.png" width="30%"/>
</p>
- 可搜索打点数据标签,展示特定数据
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86740817-809b9380-c069-11ea-9453-6531e3ff5f43.png" width="30%"/>
</p>
- 支持查看不同训练步数下的PR曲线
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86741057-b04a9b80-c069-11ea-9fef-2dcc16f9cd46.png" width="30%"/>
</p>
- X轴-时间显示类型有三种衡量尺度
- Step:迭代次数
- Walltime:训练绝对时间
- Relative:训练时长
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86741304-db34ef80-c069-11ea-86eb-787b49ed3705.png" width="30%"/>
</p>
## ROC Curve--ROC曲线组件
### 介绍
ROC曲线展示不同阈值下模型指标的变化,同时曲线下的面积(AUC)直观的反应模型表现,辅助开发者掌握模型训练情况并高效进行阈值选择。
### 记录接口
ROC Curve组件的记录接口如下:
```python
add_roc_curve(tag, labels, predictions, step=None, num_thresholds=10)
```
接口参数说明如下:
| 参数 | 格式 | 含义 |
| -------------- | --------------------- | ------------------------------------------- |
| tag | string | 记录指标的标志,如`train/loss`,不能含有`%` |
| labels | numpy.ndarray or list | 以ndarray或list格式表示的实际类别,维度为(N, ),值为0或1 |
| predictions | numpy.ndarray or list | 以ndarray或list格式表示的预测类别,维度为(N, ),值的范围应该在[0, 1] |
| step | int | 记录的roc curve曲线的步数 |
| num_thresholds | int | 阈值设置的个数,默认为10,最大值为127 |
| weights | float | 用于设置TP/FP/TN/FN在计算precision和recall时的权重 |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 |
### Demo
下面展示了使用 ROC Curve 组件记录数据的示例,代码见[ROC Curve组件](https://github.com/YixinKristy/VisualDL/blob/develop/demo/components/roc_curve_test.py)
```python
from visualdl import LogWriter
import numpy as np
# 生成一个日志记录器
with LogWriter("./log/roc_curve_test/train") as writer:
for step in range(3):
labels = np.random.randint(2, size=100)
predictions = np.random.rand(100)
# 添加一条roc数据
writer.add_roc_curve(tag='roc_curve',
labels=labels,
predictions=predictions,
step=step,
num_thresholds=5)
```
运行上述程序后,在命令行执行
```shell
visualdl --logdir ./log --port 8080
```
接着在浏览器打开`http://127.0.0.1:8080`,即可查看ROC Curve
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103344081-8928d000-4ac8-11eb-84d0-28f249886172.gif" width="80%"/>
</p>
*Note:ROC前端页面使用和PR相同,请参考上述PR Curve的使用说明。
## High Dimensional--数据降维组件
### 介绍
High Dimensional 组件将高维数据进行降维展示,用于深入分析高维数据间的关系。目前支持以下三种降维算法:
- PCA : Principle Component Analysis 主成分分析
- t-SNE : t-distributed stochastic neighbor embedding t-分布式随机领域嵌入
- umap: uniform manifold approximation and projection for dimension reduction 流形学习降维算法
### 记录接口
High Dimensional 组件的记录接口如下:
```python
add_embeddings(tag, labels, hot_vectors, walltime=None)
```
接口参数说明如下:
| 参数 | 格式 | 含义 |
| ----------- | ------------------- | ---------------------------------------------------- |
| tag | string | 记录指标的标志,如`default`,不能含有`%` |
| labels | numpy.array 或 list | 表示hot_vectors的标签,当只有一维时,labels的维度为(N, ),当有多个维度的labels时需要使用二维数组,其维度为(M, N),其中每个元素为某维度下的一维标签数组 |
| hot_vectors | numpy.array or list | 与labels一一对应,每个元素可以看作是某个标签的特征 |
| labels_meta | numpy.array or list | labels的标签,与labels一一对应,不指定则使用默认值`__metadata__`,当labels为一维数组时无需指定 |
| walltime | int | 记录数据的时间戳,默认为当前时间戳 |
### Demo
下面展示了使用 High Dimensional 组件记录数据的示例,代码见[High Dimensional组件](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/high_dimensional_test.py)
```python
from visualdl import LogWriter
if __name__ == '__main__':
hot_vectors = [
[1.3561076367500755, 1.3116267195134017, 1.6785401875616097],
[1.1039614644440658, 1.8891609992484688, 1.32030488587171],
[1.9924524852447711, 1.9358920727142739, 1.2124401279391606],
[1.4129542689796446, 1.7372166387197474, 1.7317806077076527],
[1.3913371800587777, 1.4684674577930312, 1.5214136352476377]]
labels = ["label_1", "label_2", "label_3", "label_4", "label_5"]
# 初始化一个记录器
with LogWriter(logdir="./log/high_dimensional_test/train") as writer:
# 将一组labels和对应的hot_vectors传入记录器进行记录
writer.add_embeddings(tag='default',
labels=labels,
hot_vectors=hot_vectors)
"""
# 也可以同时提供多个label,此时`labels`为二维数组,且需要提供`labels_meta`以供前端页面选择展示不同label.
labels = [["label_a_1", "label_a_2", "label_a_3", "label_a_4", "label_a_5"],
["label_b_1", "label_b_2", "label_b_3", "label_b_4", "label_b_5"]]
# labels_meta需要和labels一一对应
labels_meta = ["label_a", "label_b"]
with LogWriter(logdir="./log/high_dimensional_test/train") as writer:
writer.add_embeddings(tag='default',
labels=labels,
labels_meta=labels_meta,
hot_vectors=hot_vectors)
"""
```
运行上述程序后,在命令行执行
```shell
visualdl --logdir ./log --port 8080
```
接着在浏览器打开`http://127.0.0.1:8080`,即可查看降维后的可视化数据。
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103188111-1b32ac00-4902-11eb-914e-c2368bdb8373.gif" width="85%"/>
</p>
### 功能操作说明
* 支持选择特定实验数据进行展示,且支持根据所选择的数据标签进行展示
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103191809-4e306c00-4911-11eb-853f-e143ef86e182.png" width="30%"/>
</p>
* 降维方式--TSNE
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103192762-cea49c00-4914-11eb-896c-070b0bf0e2ea.png" width="27%"/>
</p>
* 降维方式--PCA
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103192341-47a2f400-4913-11eb-9995-fdc0acadbdc9.png" width="27%"/>
</p>
* 降维方式--UMAP
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103192766-d2d0b980-4914-11eb-871e-e4b31542c5e9.png" width="27%"/>
</p>
## VDL.service
### 简介
VisualDL可视化结果保存服务,以链接形式将可视化结果保存下来,方便用户快速、便捷的进行托管与分享。
### 使用步骤
1. 确保VisualDL已升级到最新版本,如未升级,请使用以下命令进行升级
```
pip install visualdl --upgrade
```
2. 上传需保存/分享的日志/模型文件
```
visualdl service upload --logdir ./log \
--model ./__model__
```
3. VDL.service将返回一个URL链接,复制粘贴链接至浏览器中即可查看可视化结果
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93733769-5ccc0080-fc09-11ea-88c0-6f17c04ebdce.png" width="100%"/>
</p>
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93733790-69e8ef80-fc09-11ea-9256-68a88072f5d2.png" width="100%"/>
</p>
[**中文**](./README.md)
# VisualDL Guide
### Overview
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 seven components: scalar, image, audio, graph, histogram, pr curve, ROC curve and high dimensional. VisualDL iterates rapidly and new functions will be continuously added.
| Component Name | Display Chart | Function |
| :----------------------------------------------------------: | :---------------------------: | :----------------------------------------------------------- |
| [ 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. |
| [Audio](#Audio--Audio-Play) | Audio Play | Play the audio during the training process, making it easy to monitor the process of speech recognition and text-to-speech. |
| [Text](#Text) | Text Visualization | Visualizes the text output of NLP models within any stage, aiding developers to compare the changes of outputs so as to deeply understand the training process and simply evaluate the performance of the model. |
| [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. |
| [PR Curve](#PR-Curve) | Precision & Recall Curve | Display precision-recall curves across training steps, clarifying the tradeoff between precision and recall when comparing models. |
| [ROC Curve](#ROC-Curve) | Receiver Operating Characteristic curve | Shows the performance of a classification model at all classification thresholds. |
| [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. |
At the same time, VisualDL provides [VDL.service](#vdlservice) , which allows developers to easily save, track and share visualization results of experiments with anyone for free.
## 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:
| parameter | format | meaning |
| --------- | ------ | ------------------------------------------------------------ |
| 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':
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90884030-88c54d80-e3e1-11ea-9ba7-4b8df7b3496e.png" width="100%"/>
</p>
- 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':
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90884098-a692b280-e3e1-11ea-8c0b-380b970b50b2.png" width="100%"/>
</p>
- When two parent tags are created:`acc``loss`, two rows of charts are named as 'acc' and 'loss' respectively.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90884122-b3afa180-e3e1-11ea-90b0-93a75543f253.png" width="100%"/>
</p>
### Demo
- Fundamental Methods
The following shows an example of using Scalar to record data, and the script can be found in [Scalar Demo](../../demo/components/scalar_test.py)
```python
from visualdl import LogWriter
if __name__ == '__main__':
value = [i/1000.0 for i in range(1000)]
# initialize a recorder
with LogWriter(logdir="./log/scalar_test/train") as writer:
for step in range(1000):
# add accuracy with tag of 'acc' to the recorder
writer.add_scalar(tag="acc", step=step, value=value[step])
# add loss with tag of 'loss' to the recorder
writer.add_scalar(tag="loss", step=step, value=1/(value[step] + 1))
```
After running the above program, developers can launch the panel by:
```shell
visualdl --logdir ./log --port 8080
```
Then, open the browser and enter the address: `http://127.0.0.1:8080`to view line charts:
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90871520-c9b36700-e3cd-11ea-9063-ca692b1d3917.png" width="100%"/>
</p>
- 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
from visualdl import LogWriter
if __name__ == '__main__':
value = [i/1000.0 for i in range(1000)]
# Step 1: Create a parent folder: log and a child folder: scalar_test
with LogWriter(logdir="./log/scalar_test") as writer:
for step in range(1000):
# Step 2: Add data with tag train/acc to the recorder
writer.add_scalar(tag="train/acc", step=step, value=value[step])
# Step 2: Add data with tag train/loss to the recorder
writer.add_scalar(tag="train/loss", step=step, value=1/(value[step] + 1))
# Step 1: Create a second child folder: scalar_test2
value = [i/500.0 for i in range(1000)]
with LogWriter(logdir="./log/scalar_test2") as writer:
for step in range(1000):
# Step 2: Add the accuracy data of scalar_test2 under the same name `train/acc`
writer.add_scalar(tag="train/acc", step=step, value=value[step])
# Step 2: Add the loss data of scalar_test2 under the same name as `train/loss`
writer.add_scalar(tag="train/loss", step=step, value=1/(value[step] + 1))
```
After running the above program, developers can launch the panel by:
```shell
visualdl --logdir ./log --port 8080
```
Then, open the browser and enter the address: `http://127.0.0.1:8080` to view line charts:
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90884963-4dc41980-e3e3-11ea-824a-277a8d71823e.png" width="100%"/>
</p>
*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.
<p align="center">
<img src="https://visualdl.bj.bcebos.com/images/scalar-icon.png" width="45%"/>
</p>
* Details can be shown by hovering on specific data points.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90872099-b785f880-e3ce-11ea-9ebe-8083c893d88b.png" width="60%"/>
</p>
* Developers can find target scalar charts by searching corresponded tags.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90872849-cfaa4780-e3cf-11ea-985d-b4c382acf773.png" width="90%"/>
</p>
* Specific runs can be selected by searching for the corresponded experiment tags.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90873112-2b74d080-e3d0-11ea-8a69-24b7b4abae96.png" width="40%"/>
</p>
* Display the global extrema
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93732753-46bc4100-fc05-11ea-92ca-35c89467815b.png" width="30%"/>
</p>
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93732766-58054d80-fc05-11ea-89e0-bc00a283f559.png" width="60%"/>
</p>
* Only display smoothed data
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93732799-7f5c1a80-fc05-11ea-886f-193c3bcc9b5f.png" width="30%"/>
</p>
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93732815-9569db00-fc05-11ea-8353-ffa5086d3d52.png" width="60%"/>
</p>
* There are three measurement scales of X axis
1. Step: number of iterations
2. Walltime: absolute training time
3. Relative: training time
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90873502-da191100-e3d0-11ea-8b03-c8fea0b65388.png" width="40%"/>
</p>
* The smoothness of the curve can be adjusted to better show the change of the overall trend.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90873564-edc47780-e3d0-11ea-909c-161e9fd8eeef.png" width="37%"/>
</p>
## Image--Image Visualization
### Introduction
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, dataformats="HWC")
```
The interface parameters are described as follows:
| parameter | format | meaning |
| --------- | ------------- | ------------------------------------------------------------ |
| 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 |
| dataformats| string | Format of image,include `NCHW``HWC``HW`,default is `HWC`|
### 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).
```python
import numpy as np
from PIL import Image
from visualdl import LogWriter
def random_crop(img):
"""get random 100x100 slices of image
"""
img = Image.open(img)
w, h = img.size
random_w = np.random.randint(0, w - 100)
random_h = np.random.randint(0, h - 100)
r = img.crop((random_w, random_h, random_w + 100, random_h + 100))
return np.asarray(r)
if __name__ == '__main__':
# initialize a recorder
with LogWriter(logdir="./log/image_test/train") as writer:
for step in range(6):
# add image data
writer.add_image(tag="eye",
img=random_crop("../../docs/images/eye.jpg"),
step=step)
```
After running the above program, developers can launch the panel by:
```shell
visualdl --logdir ./log --port 8080
```
Then, open the browser and enter the address: `http://127.0.0.1:8080`to view:
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90874434-4a746200-e3d2-11ea-9395-a039d9e83470.png" width="90%"/>
</p>
### Functional Instructions
- Developers can find target images by searching corresponded tags.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90875589-f8344080-e3d3-11ea-9020-52a5a88324ab.png" width="90%"/>
</p>
- Developers are allowed to view image data under different iterations by scrolling the Step/iteration slider.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90875652-10a45b00-e3d4-11ea-9fd9-3c79f22829f7.gif" width="60%"/>
</p>
## Audio--Audio Play
### Introduction
Audio aims to allow developers to listen to the audio in real-time during the training process, helping developers to monitor the process of speech recognition and text-to-speech.
### Record Interface
The interface of the Image is shown as follows:
```python
add_audio(tag, audio_array, step, sample_rate)
```
The interface parameters are described as follows:
| parameter | format | meaning |
| --------- | ------------- | ------------------------------------------------------------ |
| tag | string | Record the name of the audio,e.g.audoi/sample. Notice that the name cannot contain `%` |
| audio_arry | numpy.ndarray | Audio in ndarray format |
| step | int | Record the training steps |
| sample_rate | int | Sample rate,**Please note that the rate should be the rate of the original audio** |
### Demo
The following shows an example of using Audio to record data, and the script can be found in [Audio Demo](https://github.com/PaddlePaddle/VisualDL/blob/develop/demo/components/audio_test.py).
```python
from visualdl import LogWriter
from scipy.io import wavfile
if __name__ == '__main__':
with LogWriter(logdir="./log/audio_test/train") as writer:
sample_rate, audio_data = wavfile.read('./test.wav')
writer.add_audio(tag="audio_tag",
audio_array=audio_data,
step=0,
sample_rate=sample_rate)
```
After running the above program, developers can launch the panel by:
```shell
visualdl --logdir ./log --port 8080
```
Then, open the browser and enter the address: `http://127.0.0.1:8080`to view:
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/88753858-eaeab400-d18f-11ea-87c6-46ab7d5a5fd0.png" width="90%"/>
</p>
### Functional Instructions
- Developers can find the target audio by searching corresponded tags.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/88755034-c6dca200-d192-11ea-8349-1414bcf9d38d.png" width="80%"/>
</p>
- Developers are allowed to listen to the audio under different iterations by scrolling the Step/iteration slider.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/88755220-33f03780-d193-11ea-9b0f-a283d9f3a78a.png" width="40%"/>
</p>
- Play/Pause the audio
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/88755240-41a5bd00-d193-11ea-9780-7ae7c7792070.png" width="40%"/>
</p>
- Adjust the volume
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/88755258-53876000-d193-11ea-96b2-9ed698423202.png" width="40%"/>
</p>
- Download the audio
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/88755377-9a755580-d193-11ea-947e-4275b9d3aa54.png" width="40%"/>
</p>
## Text
### Introduction
visualizes the text output of NLP models within any stage, aiding developers to compare the changes of outputs so as to deeply understand the training process and simply evaluate the performance of the model.
### Record Interface
The interface of the Text is shown as follows:
```python
add_text(tag, text_string, step=None, walltime=None)
```
The interface parameters are described as follows:
| parameter | format | meaning |
| -------------- | --------------------- | ------------------------------------------- |
| tag | string | Record the name of the text data,e.g.train/loss. Notice that the name cannot contain `%` |
| text_string | string | Value of text |
| step | int | Record the training steps |
| walltime | int | Record the time-stamp of the data, and the default is the current time-stamp |
### Demo
The following shows an example of how to use Text component, and script can be found in [Text Demo](../../demo/components/text_test.py)
```python
from visualdl import LogWriter
if __name__ == '__main__':
texts = [
'上联: 众 佛 群 灵 光 圣 地 下联: 众 生 一 念 证 菩 提',
'上联: 乡 愁 何 处 解 下联: 故 事 几 时 休',
'上联: 清 池 荷 试 墨 下联: 碧 水 柳 含 情',
'上联: 既 近 浅 流 安 笔 砚 下联: 欲 将 直 气 定 乾 坤',
'上联: 日 丽 萱 闱 祝 无 量 寿 下联: 月 明 桂 殿 祝 有 余 龄',
'上联: 一 地 残 红 风 拾 起 下联: 半 窗 疏 影 月 窥 来'
]
with LogWriter(logdir="./log/text_test/train") as writer:
for step in range(len(texts)):
writer.add_text(tag="output", step=step, text_string=texts[step])
```
After running the above program, developers can launch the panel by:
```shell
visualdl --logdir ./log --port 8080
```
Then, open the browser and enter the address`http://127.0.0.1:8080` to view:
<p align="center">
<img src="https://user-images.githubusercontent.com/28444161/106248340-cdd09400-624b-11eb-8ea9-5a07a239c365.png" width="95%"/>
</p>
### Functional Instrucions
- Developers can find the target text by searching corresponded tags.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536503-baaa4f80-bf1a-11ea-80ab-cd988617d018.png" width="40%"/>
</p>
- Developers can find the target runs by searching corresponded tags.
<p align="center">
<img src="https://user-images.githubusercontent.com/28444161/106256983-f4e09300-6256-11eb-9acc-a24a2ac9b70c.png" width="40%"/>
</p>
- Developers can fold the tab of text.
<p align="center">
<img src="https://user-images.githubusercontent.com/28444161/106252364-28202380-6251-11eb-934c-d8893c2eaeca.png" width="80%"/>
</p>
## Graph--Network Structure
### Introduction
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:
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90877274-6548d580-e3d6-11ea-9804-74a1ead47b30.png" width="80%"/>
</p>
### Functional Instructions
- Upload the model file by one-click
- Supported model:PaddlePaddle、ONNX、Keras、Core ML、Caffe、Caffe2、Darknet、MXNet、ncnn、TensorFlow Lite
- Experimental supported model:TorchScript、PyTorch、Torch、 ArmNN、BigDL、Chainer、CNTK、Deeplearning4j、MediaPipe、ML.NET、MNN、OpenVINO、Scikit-learn、Tengine、TensorFlow.js、TensorFlow
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90877449-a80aad80-e3d6-11ea-8016-0a2f3afe6f5e.png" width="80%"/>
</p>
- Developers are allowed to drag the model up and down,left and right,zoom in and zoom out.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90878058-a097d400-e3d7-11ea-9543-bcef67ace675.gif" width="80%"/>
</p>
- Search to locate the specific node
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90878136-c0c79300-e3d7-11ea-9a14-1c1e809af442.png" width="30%"/>
</p>
- Click to view the model properties
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90878623-5531f580-e3d8-11ea-89cc-1be3500bff66.png" width="30%"/>
</p>
- Display the model information by selecting corresponded attributes
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90878712-6ed33d00-e3d8-11ea-85b9-48bf57867d30.png" width="23%"/>
</p>
- Files can be ex as PNG or SVG format
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90878893-b35ed880-e3d8-11ea-8c22-badee805bfff.png" width="30%"/>
</p>
- Click nodes to view attribute information
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90878944-c5407b80-e3d8-11ea-9db2-10e1dd1de5bf.png" width="30%"/>
</p>
- Switch the model by one-click
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90879247-34b66b00-e3d9-11ea-94ef-a26b1ba07dd0.png" width="25%"/>
</p>
## Histogram--Distribution of Tensors
### Introduction
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:
```python
add_histogram(tag, values, step, walltime=None, buckets=10)
```
The interface parameters are described as follows:
| parameter | format | meaning |
| --------- | --------------------- | ------------------------------------------------------------ |
| 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)
```python
from visualdl import LogWriter
import numpy as np
if __name__ == '__main__':
values = np.arange(0, 1000)
with LogWriter(logdir="./log/histogram_test/train") as writer:
for index in range(1, 101):
interval_start = 1 + 2 * index / 100.0
interval_end = 6 - 2 * index / 100.0
data = np.random.uniform(interval_start, interval_end, size=(10000))
writer.add_histogram(tag='default tag',
values=data,
step=index,
buckets=10)
```
After running the above program, developers can launch the panel by:
```shell
visualdl --logdir ./log --port 8080
```
Then, open the browser and enter the address: `http://127.0.0.1:8080`to view the histogram.
### Functional Instructions
- Developers are allowed to zoom in and download the histogram.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86535351-42d82700-bf12-11ea-89f0-171280e7c526.png" width="60%"/>
</p>
- Provide two modes: Offset and Overlay.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90879332-56175700-e3d9-11ea-87c3-24682191ddd4.png" width="30%"/>
</p>
- Offset mode
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536435-2b9d3780-bf1a-11ea-9981-92f837d22ae5.png" width="60%"/>
</p>
- Overlay mode
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536458-5ab3a900-bf1a-11ea-985e-05f06c1b762b.png" width="60%"/>
</p>
- Display the parameters、training steps and frequency by hovering on specific data points.
- In the 240th training step, the weight is -0.0031and the frequency is 2734
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86536482-80d94900-bf1a-11ea-9e12-5bea9f382b34.png" width="60%"/>
</p>
- Developers can find target histogram by searching corresponded tags.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90879724-ebb2e680-e3d9-11ea-9e05-9bc06691ed9c.png" width="85%"/>
</p>
- Search tags to show the histograms generated by corresponded experiments.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90879868-26b51a00-e3da-11ea-8c1d-83fb019ec668.png" width="40%"/>
</p>
## PR Curve
### Introduction
PR Curve presents precision-recall curves in line charts, describing the tradeoff relationship between precision and recall in order to choose a best threshold.
### Record Interface
The interface of the PR Curve is shown as follows:
```python
add_pr_curve(tag, labels, predictions, step=None, num_thresholds=10)
```
The interface parameters are described as follows:
| parameter | format | meaning |
| -------------- | --------------------- | ------------------------------------------- |
| 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 |
| predictions | numpy.ndarray or list | Prediction data is in ndarray or list format |
| step | int | Record the training steps |
| num_thresholds | int | Set the number of thresholds, default as 10, maximum as 127 |
| weights | float | Set the weights of TN/FN/TP/FP to calculate precision and recall |
| walltime | int | Record the time-stamp of the data, and the default is the current time-stamp |
### Demo
The following shows an example of how to use PR Curve component, and script can be found in [PR Curve Demo](../../demo/components/pr_curve_test.py)
```python
from visualdl import LogWriter
import numpy as np
with LogWriter("./log/pr_curve_test/train") as writer:
for step in range(3):
labels = np.random.randint(2, size=100)
predictions = np.random.rand(100)
writer.add_pr_curve(tag='pr_curve',
labels=labels,
predictions=predictions,
step=step,
num_thresholds=5)
```
After running the above program, developers can launch the panel by:
```shell
visualdl --logdir ./log --port 8080
```
Then, open the browser and enter the address`http://127.0.0.1:8080` to view:
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90879904-37fe2680-e3da-11ea-9369-2513620bf541.png" width="85%"/>
</p>
### Functional Instrucions
- Developers can zoom in, restore, and download PR Curves
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/86740067-f18e7b80-c068-11ea-96bf-52cb7da1f799.png" width="40%"/>
</p>
- Developers hover on the specific data point to learn about the detailed information: TP, TN, FP, FN and the corresponded thresholds
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90879971-4e0be700-e3da-11ea-989a-777b977c271d.png" width="50%"/>
</p>
- The targeted PR Curves can be displayed by searching tags
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90880145-8e6b6500-e3da-11ea-8f06-28248ee2eb84.png" width="80%"/>
</p>
- Developers can find specific labels by searching tags or view the all labels
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90880173-9fb47180-e3da-11ea-8704-34cc55c0a844.png" width="30%"/>
</p>
- Developers is able to observe the changes of PR Curves across training steps
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90880301-d2f70080-e3da-11ea-97e0-952b389f8010.png" width="30%"/>
</p>
- There are three measurement scales of X axis
1. Step: number of iterations
2. Walltime: absolute training time
3. Relative: training time
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/90880354-eace8480-e3da-11ea-921f-20f363eb1b1d.png" width="30%"/>
</p>
## ROC Curve
### Introduction
ROC Curve shows the performance of a classification model at all classification thresholds; the larger the area under the curve, the better the model performs, aiding developers to evaluate the model performance and choose an appropriate threshold.
### Record Interface
The interface of the PR Curve is shown as follows:
```python
add_roc_curve(tag, labels, predictions, step=None, num_thresholds=10)
```
The interface parameters are described as follows:
| parameter | format | meaning |
| -------------- | --------------------- | ------------------------------------------- |
| 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 |
| predictions | numpy.ndarray or list | Prediction data is in ndarray or list format |
| step | int | Record the training steps |
| num_thresholds | int | Set the number of thresholds, default as 10, maximum as 127 |
| weights | float | Set the weights of TN/FN/TP/FP to calculate precision and recall |
| walltime | int | Record the time-stamp of the data, and the default is the current time-stamp |
### Demo
The following shows an example of how to use ROC curve component, and script can be found in [ROC Curve Demo](../../demo/components/roc_curve_test.py)
```python
from visualdl import LogWriter
import numpy as np
with LogWriter("./log/roc_curve_test/train") as writer:
for step in range(3):
labels = np.random.randint(2, size=100)
predictions = np.random.rand(100)
writer.add_roc_curve(tag='roc_curve',
labels=labels,
predictions=predictions,
step=step,
num_thresholds=5)
```
After running the above program, developers can launch the panel by:
```shell
visualdl --logdir ./log --port 8080
```
Then, open the browser and enter the address`http://127.0.0.1:8080` to view:
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103344081-8928d000-4ac8-11eb-84d0-28f249886172.gif" width="85%"/>
</p>
*Note: the use of ROC Curve in the frontend is the same as that of PR Curve, please refer to the instructions in PR Curve section if needed.
## 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. Three dimensionality reduction algorithms are supported:
- PCA : Principle Component Analysis
- t-SNE : t-distributed Stochastic Neighbor Embedding
- umap: Uniform Manifold Approximation and Projection
### Record Interface
The interface of the High Dimensional is shown as follows:
```python
add_embeddings(tag, labels, hot_vectors, walltime=None)
```
The interface parameters are described as follows:
| parameter | format | meaning |
| ----------- | ------------------- | ------------------------------------------------------------ |
| 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)
```python
from visualdl import LogWriter
if __name__ == '__main__':
hot_vectors = [
[1.3561076367500755, 1.3116267195134017, 1.6785401875616097],
[1.1039614644440658, 1.8891609992484688, 1.32030488587171],
[1.9924524852447711, 1.9358920727142739, 1.2124401279391606],
[1.4129542689796446, 1.7372166387197474, 1.7317806077076527],
[1.3913371800587777, 1.4684674577930312, 1.5214136352476377]]
labels = ["label_1", "label_2", "label_3", "label_4", "label_5"]
# initialize a recorder
with LogWriter(logdir="./log/high_dimensional_test/train") as writer:
# recorde a set of labels and corresponding hot_vectors to the recorder
writer.add_embeddings(tag='default',
labels=labels,
hot_vectors=hot_vectors)
```
After running the above program, developers can launch the panel by:
```shell
visualdl --logdir ./log --port 8080
```
Then, open the browser and enter the address`http://127.0.0.1:8080` to view:
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103188111-1b32ac00-4902-11eb-914e-c2368bdb8373.gif" width="85%"/>
</p>
### Functional Instrucions
* Developers are allowed to select specific runs of data or certain labels of data to display
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103191809-4e306c00-4911-11eb-853f-e143ef86e182.png" width="30%"/>
</p>
* TSNE
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103192762-cea49c00-4914-11eb-896c-070b0bf0e2ea.png" width="27%"/>
</p>
* PCA
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103192341-47a2f400-4913-11eb-9995-fdc0acadbdc9.png" width="27%"/>
</p>
* UMAP
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103192766-d2d0b980-4914-11eb-871e-e4b31542c5e9.png" width="27%"/>
</p>
## VDL.service
### Introduction
VDL.service enables developers to easily save, track and share visualization results with anyone for free.
### Usage Steps
1. Make sure that your get the lastest version of VisualDL, if not, please update by:
```
pip install visualdl --upgrade
```
2. Upload log/model to save, track and share the visualization results.
```
visualdl service upload --logdir ./log \
--model ./__model__
```
3. An unique URL will be given. Then you can view the visualization results by simply copying and pasting the URL to the browser.
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93733769-5ccc0080-fc09-11ea-88c0-6f17c04ebdce.png" width="100%"/>
</p>
<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/93734496-057b5f80-fc0c-11ea-9b52-229ff8847bc0.png" width="100%"/>
</p>
# 常见问题 # Frequently Asked Questions
[**English**](./faq_EN.md) [**中文**](./faq_CN.md)
## 打开浏览器出现空白或者发生错误 ## How can I do when I see a blank page or error messages in the browser?
可参照下列步骤排除错误原因 To work out bugs, you can follow the steps:
1. 确保启动VisualDL时指定的`logdir`路径正确,并确保其下有符合命名要求(文件名包含`vdlrecords`)的日志文件,可进入`logdir`指定的文件夹先行查看。若未解决,转下步。 1. You should ensure that the `logdir` path set by VisualDL is correct. In the meanwhile, there must be a log file and its name (including `vdlrecords`) should be correct. And then you can check the folder set by `logdir`. If it is not okay, try the next step.
2. 确认浏览器及版本符合VisualDL要求,建议使用**最新版本**的chrome及chrome内核浏览器、火狐浏览器,尝试更换浏览器及升级到最新版本。若未解决,转下步。 2. Please check the browser and its version, and ensure it fits VisualDL. We suggest using **the latest versions** of Chrome browser, browsers with Chrome’s kernel, Firefox browser. Please change browsers and upgrade it to the latest version. If it is not okay, try the next step.
3.`--host`参数指定为`0.0.0.0``127.0.0.1`,注意后者仅支持本机查看,若在服务器启动并在异地查看,需使用`0.0.0.0`并确保使用的端口可被外网访问。若未解决,转下步。 3. Please specify `--host`as `0.0.0.0` or `127.0.0.1`. And the latter one only supports the local address. If the server runs and you want to check by other addresses, please use `0.0.0.0` and ensure the end can be visited by outer net. If it is not okay, try the next step.
4. 关闭并重新打开VisualDL前端页面,或强制刷新浏览器并等待15-30秒。若未解决,转下步。 4. Close and re-open the front-end page of VisualDL. Or do a hard refresh on the browser and wait for 15-30 seconds. If it is not okay, try the next step.
5. 若是windows机器,可查看是否注册表被修改,参考解决[解决注册表修改导致无法查看日志](https://github.com/PaddlePaddle/VisualDL/issues/834) 5. If you use windows, please check whether the registry is modified. For users who want to get into more details, please refer to https://github.com/PaddlePaddle/VisualDL/issues/834. If all the steps do not work, please ask questions in VisualDL GitHub Issue. The link is [VDL Issue](https://github.com/PaddlePaddle/VisualDL/issues).
若经过上述尝试仍无法解决,可在VisualDL GitHub Issue进行提问[VDL Issue](https://github.com/PaddlePaddle/VisualDL/issues)
## 使用Image、Audio、Text组件仅显示10个样本 ## When I use modules of Image, Audio and Text, there are only ten samples.
为保证使用体验,防止由于数据量过大造成前端页面卡死或崩溃,在展示Image、Audio、Text组件时使用采样算法进行了数据采样后展示。 We apply random sampling algorithm to display sampled data, when using modules of Image, Audio and Text. In this way, the front-end page will not be stuck or will not crash because of too much data, and then we can ensure users’ experience.
尽管数据在前端展示进行了采样,但在日志中保存的数据仍为全部数据,可通过`VisualDL.LogReader`进行全部数据获取,可参考[LogReader使用教程](./components#LogReader)
Though data shown in the front-page are sampled, all the data are saved in the log file. You can obtain all the data by using `VisualDL.LogReader`. For more details, please refer to our [LogReader tutorial](./components#LogReader).
## Why are the curves drawn by Scalar twisty?
Because there are two or more values in a certain step, you will find the curves you draw are like the following picture. Please check your script and find whether you add several values to one step, when using`add_scalar`.
## 为什么Scalar绘制的曲线是迂回的
当你发现绘制的曲线如下图所示,某个step对应的value不止一个值时,请检查你的脚本,是否在使用`add_scalar`时为一个step重复添加了多次value。
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/28444161/99496785-de44d280-29af-11eb-8fbd-ebc7a4919f2f.png" width="40%"/> <img src="https://user-images.githubusercontent.com/28444161/99496785-de44d280-29af-11eb-8fbd-ebc7a4919f2f.png" width="40%"/>
</p> </p>
## 官方用例报错,LogWriter对象没有mode属性 ## How can I do when confronted with the error of official use cases, saying that the target of LogWriter does not have the mode attribute?
Please check the version of VisualDL you use (which visualdl). According to the error, it is most likely that you are using the VisualDL 1.3, which attributes to Python 2 you use. Python 2 will install the old version of VisualDL automatically.
At present, VisualDL does not support Python 2 any more. And the instructions of existing official documents ae based on VisualDL 2.0, which also will not support Python 2. We suggest upgrading the Python's version to Python 3 and installing the latest version of VisualDL. In this way, the problem will not appear again.
## How to modify an existing log file
Different needs have different solutions
1. If you need to continue to add logs to an existing log file, please specify the file_name parameter as the log name when using LogWriter to obtain the log generator, and this log will be written when subsequent data is added.
2. If you need to add or delete some data in the log, you can read the log through LogReader and process it, and then write it back to a new file. Please refer to LogReader Tutorial.
可以检查一下使用的VisualDL的版本(which visualdl),因为按照此报错来看,大概率是因使用的是Python2,自动安装了VisualDL 1.3版本,但官方示例均基于2.0版本的,故导致此报错。 ## What are the sampling rules of VisualDL
由于目前VisualDL已经不维护python2了,且现有官方文档上的使用说明都是基于2.0版本的,并且将不再维护旧版本,建议升级至Python3,安装最新版的VisualDL,即不会出现上述问题。 In order to minimize the CPU resource occupation for sampling, we improve the efficiency of data transmission and make the sampling uniform by using a reservoir sampling algorithm. In this way, all the data will be sampled in the back-end and then transmitted to the front-end. Reservoir Sampling can avoid loading all data through streaming sampling at once. For more details of the sampling theory, please refer to Reservoir Sampling.
\ No newline at end of file
# 常见问题
[**English**](./faq.md)
## 打开浏览器出现空白或者发生错误
可参照下列步骤排除错误原因
1. 确保启动VisualDL时指定的`logdir`路径正确,并确保其下有符合命名要求(文件名包含`vdlrecords`)的日志文件,可进入`logdir`指定的文件夹先行查看。若未解决,转下步。
2. 确认浏览器及版本符合VisualDL要求,建议使用**最新版本**的chrome及chrome内核浏览器、火狐浏览器,尝试更换浏览器及升级到最新版本。若未解决,转下步。
3.`--host`参数指定为`0.0.0.0``127.0.0.1`,注意后者仅支持本机查看,若在服务器启动并在异地查看,需使用`0.0.0.0`并确保使用的端口可被外网访问。若未解决,转下步。
4. 关闭并重新打开VisualDL前端页面,或强制刷新浏览器并等待15-30秒。若未解决,转下步。
5. 若是windows机器,可查看是否注册表被修改,参考解决[解决注册表修改导致无法查看日志](https://github.com/PaddlePaddle/VisualDL/issues/834)
若经过上述尝试仍无法解决,可在VisualDL GitHub Issue进行提问[VDL Issue](https://github.com/PaddlePaddle/VisualDL/issues)
## 使用Image、Audio、Text组件仅显示10个样本
为保证使用体验,防止由于数据量过大造成前端页面卡死或崩溃,在展示Image、Audio、Text组件时使用采样算法进行了数据采样后展示。
尽管数据在前端展示进行了采样,但在日志中保存的数据仍为全部数据,可通过`VisualDL.LogReader`进行全部数据获取,可参考[LogReader使用教程](./components#LogReader)
## 为什么Scalar绘制的曲线是迂回的
当你发现绘制的曲线如下图所示,某个step对应的value不止一个值时,请检查你的脚本,是否在使用`add_scalar`时为一个step重复添加了多次value。
<p align="center">
<img src="https://user-images.githubusercontent.com/28444161/99496785-de44d280-29af-11eb-8fbd-ebc7a4919f2f.png" width="40%"/>
</p>
## 官方用例报错,LogWriter对象没有mode属性
可以检查一下使用的VisualDL的版本(which visualdl),因为按照此报错来看,大概率是因使用的是Python2,自动安装了VisualDL 1.3版本,但官方示例均基于2.0版本的,故导致此报错。
由于目前VisualDL已经不维护python2了,且现有官方文档上的使用说明都是基于2.0版本的,并且将不再维护旧版本,建议升级至Python3,安装最新版的VisualDL,即不会出现上述问题。
## 如何修改已有的日志文件
不同的需求距有不同的解决思路
1. 如果需要在已有的日志文件中继续添加日志,则在使用LogWriter获取日志生成器时指定`file_name`参数为此日志名,则后续添加数据时都会写入此日志。
2. 如果需要增加或删除日志中某些数据,则可以通过LogReader读取日志并处理后,重新写入到新的文件中,可参考[LogReader使用教程](./components#LogReader)
## VisualDL的采样规则是什么
为了尽量减少数据传输规模且尽可能均匀化采样,同时最小化采样所需的CPU资源占用,VisualDL使用蓄水池采样算法完成对后端所有数据采样后再向前端传输。
关于蓄水池采样的原理和证明,可参考[Reservoir sampling](https://en.wikipedia.org/wiki/Reservoir_sampling),蓄水池采样能够通过流式采样的方式避免一次性加载所有数据到内存,且保证采样序列尽量平均。
# Frequently Asked Questions
[**中文**](./faq.md)
## How can I do when I see a blank page or error messages in the browser?
To work out bugs, you can follow the steps:
1. You should ensure that the `logdir` path set by VisualDL is correct. In the meanwhile, there must be a log file and its name (including `vdlrecords`) should be correct. And then you can check the folder set by `logdir`. If it is not okay, try the next step.
2. Please check the browser and its version, and ensure it fits VisualDL. We suggest using **the latest versions** of Chrome browser, browsers with Chrome’s kernel, Firefox browser. Please change browsers and upgrade it to the latest version. If it is not okay, try the next step.
3. Please specify `--host`as `0.0.0.0` or `127.0.0.1`. And the latter one only supports the local address. If the server runs and you want to check by other addresses, please use `0.0.0.0` and ensure the end can be visited by outer net. If it is not okay, try the next step.
4. Close and re-open the front-end page of VisualDL. Or do a hard refresh on the browser and wait for 15-30 seconds. If it is not okay, try the next step.
5. If you use windows, please check whether the registry is modified. For users who want to get into more details, please refer to https://github.com/PaddlePaddle/VisualDL/issues/834. If all the steps do not work, please ask questions in VisualDL GitHub Issue. The link is [VDL Issue](https://github.com/PaddlePaddle/VisualDL/issues).
## When I use modules of Image, Audio and Text, there are only ten samples.
We apply random sampling algorithm to display sampled data, when using modules of Image, Audio and Text. In this way, the front-end page will not be stuck or will not crash because of too much data, and then we can ensure users’ experience.
Though data shown in the front-page are sampled, all the data are saved in the log file. You can obtain all the data by using `VisualDL.LogReader`. For more details, please refer to our [LogReader tutorial](./components#LogReader).
## Why are the curves drawn by Scalar twisty?
Because there are two or more values in a certain step, you will find the curves you draw are like the following picture. Please check your script and find whether you add several values to one step, when using`add_scalar`.
<p align="center">
<img src="https://user-images.githubusercontent.com/28444161/99496785-de44d280-29af-11eb-8fbd-ebc7a4919f2f.png" width="40%"/>
</p>
## How can I do when confronted with the error of official use cases, saying that the target of LogWriter does not have the mode attribute?
Please check the version of VisualDL you use (which visualdl). According to the error, it is most likely that you are using the VisualDL 1.3, which attributes to Python 2 you use. Python 2 will install the old version of VisualDL automatically.
At present, VisualDL does not support Python 2 any more. And the instructions of existing official documents ae based on VisualDL 2.0, which also will not support Python 2. We suggest upgrading the Python's version to Python 3 and installing the latest version of VisualDL. In this way, the problem will not appear again.
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册