Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
cf66d953
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
大约 1 年 前同步成功
通知
88
Star
4655
Fork
642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VisualDL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
cf66d953
编写于
12月 23, 2020
作者:
走神的阿圆
提交者:
GitHub
12月 23, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support float32 and double64 of ndarray
上级
e5150df6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
11 deletion
+26
-11
visualdl/component/base_component.py
visualdl/component/base_component.py
+26
-11
未找到文件。
visualdl/component/base_component.py
浏览文件 @
cf66d953
...
...
@@ -60,7 +60,7 @@ def imgarray2bytes(np_array):
"""Convert image ndarray to bytes.
Args:
np_array (n
umpy
.ndarray): Array to converte.
np_array (n
p
.ndarray): Array to converte.
Returns:
Binary bytes of np_array.
...
...
@@ -106,7 +106,7 @@ def convert_to_HWC(tensor, input_format):
"""Convert `NCHW`, `HWC`, `HW` to `HWC`
Args:
tensor (n
umpy
.ndarray): Value of image
tensor (n
p
.ndarray): Value of image
input_format (string): Format of image
Return:
...
...
@@ -138,12 +138,26 @@ def convert_to_HWC(tensor, input_format):
return
tensor
def
denormalization
(
image_array
):
"""Renormalise ndarray matrix.
Args:
image_array(np.ndarray): Value of image
Return:
Matrix after renormalising.
"""
if
image_array
.
max
()
<=
1
and
image_array
.
min
()
>=
0
:
image_array
*=
255
return
image_array
.
astype
(
np
.
uint8
)
def
image
(
tag
,
image_array
,
step
,
walltime
=
None
,
dataformats
=
"HWC"
):
"""Package data to one image.
Args:
tag (string): Data identifier
image_array (n
umpy.ndarray): Value of iam
ge
image_array (n
p.ndarray): Value of ima
ge
step (int): Step of image
walltime (int): Wall time of image
dataformats (string): Format of image
...
...
@@ -151,6 +165,7 @@ def image(tag, image_array, step, walltime=None, dataformats="HWC"):
Return:
Package with format of record_pb2.Record
"""
image_array
=
denormalization
(
image_array
)
image_array
=
convert_to_HWC
(
image_array
,
dataformats
)
image_bytes
=
imgarray2bytes
(
image_array
)
image
=
Record
.
Image
(
encoded_image_string
=
image_bytes
)
...
...
@@ -165,7 +180,7 @@ def embedding(tag, labels, hot_vectors, step, labels_meta=None, walltime=None):
Args:
tag (string): Data identifier
labels (list): A list of labels.
hot_vectors (n
umpy
.array or list): A matrix which each row is
hot_vectors (n
p
.array or list): A matrix which each row is
feature of labels.
step (int): Step of embeddings.
walltime (int): Wall time of embeddings.
...
...
@@ -199,7 +214,7 @@ def audio(tag, audio_array, sample_rate, step, walltime):
Args:
tag (string): Data identifier
audio_array (n
umpy.ndarray or list): audio represented by a numpy
.array
audio_array (n
p.ndarray or list): audio represented by a np
.array
sample_rate (int): Sample rate of audio
step (int): Step of audio
walltime (int): Wall time of audio
...
...
@@ -246,8 +261,8 @@ def histogram(tag, hist, bin_edges, step, walltime):
Args:
tag (string): Data identifier
hist (n
umpy
.ndarray or list): The values of the histogram
bin_edges (n
umpy
.ndarray or list): The bin edges
hist (n
p
.ndarray or list): The values of the histogram
bin_edges (n
p
.ndarray or list): The bin edges
step (int): Step of histogram
walltime (int): Wall time of histogram
...
...
@@ -265,8 +280,8 @@ def compute_curve(labels, predictions, num_thresholds=None, weights=None):
""" Compute precision-recall curve data by labels and predictions.
Args:
labels (n
umpy
.ndarray or list): Binary labels for each element.
predictions (n
umpy
.ndarray or list): The probability that an element be
labels (n
p
.ndarray or list): Binary labels for each element.
predictions (n
p
.ndarray or list): The probability that an element be
classified as true.
num_thresholds (int): Number of thresholds used to draw the curve.
weights (float): Multiple of data to display on the curve.
...
...
@@ -318,8 +333,8 @@ def pr_curve(tag, labels, predictions, step, walltime, num_thresholds=127,
Args:
tag (string): Data identifier
labels (n
umpy
.ndarray or list): Binary labels for each element.
predictions (n
umpy
.ndarray or list): The probability that an element be
labels (n
p
.ndarray or list): Binary labels for each element.
predictions (n
p
.ndarray or list): The probability that an element be
classified as true.
step (int): Step of pr_curve
walltime (int): Wall time of pr_curve
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录