Package: visualdl
中文IntroductionVisualDL, 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 , ROC 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, includingtracking metrics in real-time, visualizing the model structure, displaying the data sample, visualizing the relationship between hyperparameters and model metrics, 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 toVisualDL User Guide. For up-to-date experience, please feel free to try ourOnline Demo. Currently, VisualDL iterates rapidly and new functions will be continuously added.Browsers supported by VisualDL are:Google Chrome ≥ 79Firefox ≥ 67Microsoft Edge ≥ 79Safari ≥ 11.1VisualDL 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.ContentsKey HighlightsInstallationUsage GuidelineFunction PreviewFrequently Asked QuestionsContributionMore DetailsTechnical CommunicationKey HighlightsEasy to UseThe high-level design of API makes it easy to use. Only one click can initiate the visualization of model structures.Various FunctionsThe function contains the visualization of training parameters, data samples, graph structures, histograms of tensors, PR curves and high-dimensional data distributions.High CompatibilityVisualDL provides the visualization of the mainstream model structures such as Paddle, ONNX, Caffe, widely supporting visual analysis for diverse users.Fully SupportBy Integrating into PaddlePaddle and related modules, VisualDL allows developers to use different components without obstructions, and thus to have the best experience in the PaddlePaddle ecosystem.InstallationInstall by PiPpython-mpipinstallvisualdl-ihttps://mirror.baidu.com/pypi/simpleInstall by Codegit clone https://github.com/PaddlePaddle/VisualDL.git
cd VisualDL

python setup.py bdist_wheel
pip install --upgrade dist/visualdl-*.whlPlease 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 GuidelineVisualDL 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. LogThe 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:classLogWriter(logdir=None,max_queue=10,flush_secs=120,filename_suffix='',**kwargs)Interface ParametersparameterstypemeaninglogdirstringThe 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 beruns/${CURRENT_TIME}as default.max_queueintThe 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.flush_secsintThe 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)filename_suffixstringAdd a suffix to the default log file name.display_namestringThis parameter is displayed in the location ofSelect Data Streamin the panel. If not set, the default name islogdir.(Whenlogdiris too long or needed to be hidden).file_namestringSet 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'.ExampleCreate a log file and record scalar values:fromvisualdlimportLogWriter# create a log file under `./log/scalar_test/train`withLogWriter(logdir="./log/scalar_test/train")aswriter:# use `add_scalar` to record scalar valueswriter.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)# you can also use the following method without using context manager `with`:"""writer = LogWriter(logdir="./log/scalar_test/train")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)writer.close()"""2. Launch PanelIn the above example, the log has recorded three sets of scalar values. Developers can view the visualization results of the log file through launching the visualDL panel. There are two ways to launch the log file:Launch by Command LineUse the command line to launch the VisualDL panel：visualdl--logdir<dir_1,dir_2,...,dir_n>--model<model_file>--host<host>--port<port>--cache-timeout<cache_timeout>--language<language>--public-path<public_path>--api-only--component_tabs<tab_name1,tab_name2,...>Parameter details:parametersmeaning--logdirSet one or more directories of the log. All the logs in the paths or subdirectories will be displayed on the VisualDL Board indepentently.--modelSet 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 toGraph - Functional Instructions.--hostSpecify IP address. The default value is127.0.0.1. Specify it as0.0.0.0or public IP address so that other machines can visit VisualDL Board.--portSet the port. The default value is8040.--cache-timeoutCache 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.--languageThe language of the VisualDL panel. Language can be specified as 'en' or 'zh', and the default is the language used by the browser.--public-pathThe URL path of the VisualDL panel. The default path is '/app', meaning that the access address is 'http://<host>:<port>/app'.--api-onlyDecide 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://<host>:<port>/<public_path>/api'. Additionally, If the public_path parameter is not specified, the default address is 'http://<host>:<port>/api'.--component_tabsDecide which components are presented in page, currently support 15 components, i.e. 'scalar', 'image', 'text', 'embeddings', 'audio', 'histogram', 'hyper_parameters', 'static_graph', 'dynamic_graph', 'pr_curve', 'roc_curve', 'profiler', 'x2paddle', 'fastdeploy_server', 'fastdeploy_client'. If this parameter is set, only specified components will be presented. If not set, and specify --logdir parameter, only components with data in vdlrecords log are presented. If both --component_tabs and --logdir are not set, only present 'static_graph', 'x2paddle', 'fastdeploy_server', 'fastdeploy_client' components by defaultTo visualize the log file generated in the previous step, developers can launch the panel through the command:visualdl --logdir ./logLaunch in Python ScriptDevelopers can start the VisualDL panel in Python script as follows:visualdl.server.app.run(logdir,model="path/to/model",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 exceptlogdir, developers should specify parameter names when using them.The interface parameters are as follows:parameterstypemeaninglogdirstring 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.modelstringSet a path to the model file (not a directory). VisualDL will visualize the model file in Graph page.hoststringSpecify IP address. The default value is127.0.0.1. Specify it as0.0.0.0or public IP address so that other machines can visit VisualDL Board.portintSet the port. The default value is8040.cache_timeoutintCache 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.languagestringThe language of the VisualDL panel. Language can be specified as 'en' or 'zh', and the default is the language used by the browser.public_pathstringThe URL path of the VisualDL panel. The default path is '/app', meaning that the access address is 'http://<host>:<port>/app'.api_onlybooleanDecide 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://<host>:<port>/<public_path>/api'. Additionally, If the parameter public_path is not specified, the default address is 'http://<host>:<port>/api'.open_browserbooleanWhether or not to open the browser. If this parameter is set as True, the browser will be opened 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.component_tabsstring or list[string_1, string_2, ... , string_n]Decide which components are presented in page, currently support 15 components, i.e. 'scalar', 'image', 'text', 'embeddings', 'audio', 'histogram', 'hyper_parameters', 'static_graph', 'dynamic_graph', 'pr_curve', 'roc_curve', 'profiler', 'x2paddle', 'fastdeploy_server', 'fastdeploy_client'. If this parameter is set, only specified components will be presented. If not set, and specify --logdir parameter, only components with data in vdlrecords log are presented. If both --component_tabs and --logdir are not set, only present 'static_graph', 'x2paddle', 'fastdeploy_server', 'fastdeploy_client' components by defaultTo visualize the log file generated in the previous step, developers can launch the panel through the command:fromvisualdl.serverimportappapp.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:3. Read data in log files using LogReaderVisualDL also providesLogReaderinterface to read any data from log files.classLogReader(file_path='')Interface Parametersparameterstypemeaningfile_pathstringFile path of the log file. Required.ExampleIf there is a log file namedvdlrecords.1605533348.login the directory of./log, we can retrieve the data under the 'loss' tag in the scalar by:fromvisualdlimportLogReaderreader=LogReader(file_path='./vdlrecords.1605533348.log')data=reader.get_data('scalar','loss')print(data)The result will be a list shown as below：...id:5tag:"Metrics/Training(Step): loss"timestamp:1605533356039value:3.1297709941864014...For more information ofLogReader, please refer toLogReader.Function PreviewScalarScalarmakes use of various charts to display how the parameters, such as accuracy, loss and learning rate, changes 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 DisplayAfter the launch of VisualDL Board, the LogReader will continuously record the data to display in the front-end. Hence, the changes of parameters can be visualized in real-time, as shown below:Comparison of Multiple ExperimentsDevelopers can compare 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.ImageImageprovides real-time visualizations of the image data during the training process, allowing developers to observe the changes of images at different training stages and  to deeply understand the effects of the training process.AudioAudioaims 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.TextTextvisualizes 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.GraphGraphenables developers to visualize model structures by only one click. Moreover,Graphallows developers to explore model attributes, node information, node input and output. aiding them analyze model structures quickly and understand the direction of data flow easily. Additionally, Graph supports the visualization of dynamic and static model graph respectively.dynamic graphstatic graphHistogramHistogramdisplays how the trend of tensor (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 ModeOverlay ModePR CurvePR Curvedisplays the precision and recall values under different thresholds, helping developers to find the best threshold efficiently.ROC CurveROC Curveshows the performance of a classification model at all classification thresholds; the larger the area under the curve, the better the model performs, aiding developers in evaluating the model performance and choosing an appropriate threshold.High DimensionalHigh Dimensionalprovides three approaches--T-SNE, PCA and UMAP--to do the dimensionality reduction, allowing developers to have an in-depth analysis of the relationship between high-dimensional data and to optimize algorithms based on the analysis.Hyper ParametersHyper Parametersvisualize the relationship between hyperparameters and model metrics (such as accuracy and loss) in a rich view, helping you identify the best hyperparameters in an efficient way.Performance AnalysisPerformance Analysis(Profiler) visualize the profiling data collected during your program runs, helping you identify program bottlenecks and optimize performance. Please refer toVisualDL Profiler Guide。Performance AnalysisPerformance Analysis(Profiler) visualize the profiling data collected during your program runs, helping you identify program bottlenecks and optimize performance. Please refer toVisualDL Profiler Guide.X2PaddleThe X2Paddle component provides the functions of onnx model format visualization and transformation to paddle format.FastDeployServerThe FastDeployServer component provides the functions of loading and editing the model repository, fastdeployserver service management and monitoring, and providing the client to test service. Please refer touse VisualDL for fastdeploy serving deployment visualization.FastDeployClientThe FastDeployClient component is mainly used to quickly access the fastdeployserver service, to help users visualize prediction requests and results. Please refer touse VisualDL as fastdeploy client for request visualization.VDL.serviceVDL.serviceenables developers to easily save, track and share visualization results with anyone for free.Frequently Asked QuestionsIf you are confronted with some problems when using VisualDL, please refer toour FAQs.ContributionVisualDL, in which Graph is powered byNetron, is an open source project supported byPaddlePaddleandECharts.Developers are warmly welcomed to use, comment and contribute.More DetailsFor more details related to the use of VisualDL, please refer toVisualDL User Guide,VisualDL Profiler Guide,Use VisualDL for fastdeploy serving deployment visualization,Use VisualDL as fastdeploy client for request visualization.Technical CommunicationWelcome to join the official QQ group 1045783368 to communicate with PaddlePaddle team and other developers.