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

add doc for LogReader in README.md (#892)

* add doc for LogReader in README.md

* fix review
上级 2bb4183e
......@@ -221,6 +221,38 @@ After launching the panel by one of the above methods, developers can see the vi
<img src="https://user-images.githubusercontent.com/48054808/90868674-ba321f00-e3c9-11ea-83c1-f03c6dd19187.png" width="70%"/>
</p>
### 3. Read data in log files using LogReader
VisualDL also provides `LogReader` interface to read raw data from log files.
```python
class LogReader(file_path='')
```
#### interface parameters
| parameters | type | meaning |
| ---------- | ------ | ------------------------------------ |
| file_path | string | File path of the log file. Required. |
#### Example
If there is a log file named `vdlrecords.1605533348.log` in the directory of `./log`, we can retrieve the data under the 'loss' tag in the scalar by:
```python
from visualdl import LogReader
reader = LogReader(file_path='./vdlrecords.1605533348.log')
data = reader.get_data('scalar', 'loss')
print(data)
```
The result will be a list shown as below:
```python
...
id: 5
tag: "Metrics/Training(Step): loss"
timestamp: 1605533356039
value: 3.1297709941864014
...
```
For more information of `LogReader`, please refer to [LogReader](./docs/io/LogReader.md).
## Function Preview
### Scalar
......
......@@ -230,25 +230,23 @@ app.run(logdir="./log")
VisualDL的后端也提供了获取日志数据的组件`LogReader`,可通过其获取日志中任意数据,接口如下:
```python
class LogReader(logdir=None,
file_name='')
class LogReader(file_path='')
```
#### 接口参数
| 参数 | 格式 | 含义 |
| --------- | ------ | -------------------------- |
| logdir | string | 日志文件所在的路径,必填 |
| file_name | string | 指定要读的日志文件名,必填 |
| 参数 | 格式 | 含义 |
| --------------- | ------- | ------------------------------------------------------------ |
| file_path | string | 指定要读的日志文件路径,必填,注意这里与file_name不同,需填写具体路径|
#### 示例
假定在`./log`文件夹下有一个日志文件`vdlrecords.1605533348.log`,则获取此日志中tag为`loss`的scalar数据过程如下:
假定在`./log`文件夹下有一个日志文件`vdlrecords.1605533348.log`,则获取LogReader实例如下:
```python
from visualdl import LogReader
reader = LogReader(logdir='./log', file_name='vdlrecords.1605533348.log')
reader = LogReader(file_path='./log/vdlrecords.1605533348.log')
data = reader.get_data('scalar', 'loss')
print(data)
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册