Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
c678924e
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
大约 2 年 前同步成功
通知
89
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看板
“0bb9c80ef960d777c5937f8fed8ddf75f2ac6a18”上不存在“paddle/phi/kernels/cpu/adadelta_kernel.cc”
未验证
提交
c678924e
编写于
1月 16, 2018
作者:
Y
Yan Chunwei
提交者:
GitHub
1月 16, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Feature/add scratch demo (#150)
上级
ec572c0d
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
28 addition
and
17 deletion
+28
-17
demo/mxnet/mxnet_demo.py
demo/mxnet/mxnet_demo.py
+2
-2
demo/paddle/cifar10_image_classification_vgg.py
demo/paddle/cifar10_image_classification_vgg.py
+4
-3
demo/vdl_scratch.py
demo/vdl_scratch.py
+22
-12
未找到文件。
demo/mxnet/mxnet_demo.py
浏览文件 @
c678924e
import
mxnet
as
mx
import
logging
import
mxnet
as
mx
# Here we import LogWriter so that we can write log data while MXNet is training
# Here we import LogWriter so that we can write log data while MXNet is training
from
visualdl
import
LogWriter
from
visualdl
import
LogWriter
...
@@ -45,7 +46,6 @@ def add_scalar():
...
@@ -45,7 +46,6 @@ def add_scalar():
# Start to build CNN in MXNet, train MNIST dataset. For more info, check MXNet's official website:
# Start to build CNN in MXNet, train MNIST dataset. For more info, check MXNet's official website:
# https://mxnet.incubator.apache.org/tutorials/python/mnist.html
# https://mxnet.incubator.apache.org/tutorials/python/mnist.html
import
logging
logging
.
getLogger
().
setLevel
(
logging
.
DEBUG
)
# logging to stdout
logging
.
getLogger
().
setLevel
(
logging
.
DEBUG
)
# logging to stdout
train_iter
=
mx
.
io
.
NDArrayIter
(
mnist
[
'train_data'
],
mnist
[
'train_label'
],
batch_size
,
shuffle
=
True
)
train_iter
=
mx
.
io
.
NDArrayIter
(
mnist
[
'train_data'
],
mnist
[
'train_label'
],
batch_size
,
shuffle
=
True
)
...
...
demo/paddle/cifar10_image_classification_vgg.py
浏览文件 @
c678924e
...
@@ -2,13 +2,14 @@ from __future__ import print_function
...
@@ -2,13 +2,14 @@ from __future__ import print_function
import
sys
import
sys
import
numpy
as
np
from
visualdl
import
LogWriter
import
paddle.v2
as
paddle
import
paddle.v2
as
paddle
import
paddle.v2.fluid
as
fluid
import
paddle.v2.fluid
as
fluid
import
paddle.v2.fluid.framework
as
framework
import
paddle.v2.fluid.framework
as
framework
from
paddle.v2.fluid.param_attr
import
ParamAttr
from
paddle.v2.fluid.initializer
import
NormalInitializer
from
paddle.v2.fluid.initializer
import
NormalInitializer
from
visualdl
import
LogWriter
from
paddle.v2.fluid.param_attr
import
ParamAttr
import
numpy
as
np
logdir
=
"./tmp"
logdir
=
"./tmp"
logwriter
=
LogWriter
(
logdir
,
sync_cycle
=
10
)
logwriter
=
LogWriter
(
logdir
,
sync_cycle
=
10
)
...
...
demo/vdl_scratch.py
浏览文件 @
c678924e
#!/user/bin/env python
#!/user/bin/env python
import
math
import
os
import
os
from
visualdl
import
LogWriter
,
ROOT
import
random
import
subprocess
import
subprocess
from
scipy.stats
import
norm
import
numpy
as
np
import
numpy
as
np
import
random
from
PIL
import
Image
from
PIL
import
Image
from
scipy.stats
import
norm
from
visualdl
import
ROOT
,
LogWriter
logdir
=
'./scratch_log'
logdir
=
'./scratch_log'
...
@@ -19,22 +21,29 @@ with logw.mode('test') as logger:
...
@@ -19,22 +21,29 @@ with logw.mode('test') as logger:
scalar1
=
logger
.
scalar
(
"scratch/scalar"
)
scalar1
=
logger
.
scalar
(
"scratch/scalar"
)
# add scalar records.
# add scalar records.
for
step
in
range
(
200
):
last_record0
=
0.
scalar0
.
add_record
(
step
,
step
*
1.
/
200
)
last_record1
=
0.
scalar1
.
add_record
(
step
,
1.
-
step
*
1.
/
200
)
for
step
in
range
(
1
,
100
):
last_record0
+=
0.1
*
(
random
.
random
()
-
0.3
)
last_record1
+=
0.1
*
(
random
.
random
()
-
0.7
)
scalar0
.
add_record
(
step
,
last_record0
)
scalar1
.
add_record
(
step
,
last_record1
)
# create histogram
# create histogram
with
logw
.
mode
(
'train'
)
as
logger
:
with
logw
.
mode
(
'train'
)
as
logger
:
histogram
=
logger
.
histogram
(
"scratch/histogram"
,
num_buckets
=
1
00
)
histogram
=
logger
.
histogram
(
"scratch/histogram"
,
num_buckets
=
2
00
)
for
step
in
range
(
100
):
for
step
in
range
(
1
,
1
00
):
histogram
.
add_record
(
step
,
histogram
.
add_record
(
step
,
np
.
random
.
normal
(
0.1
+
step
*
0.01
,
size
=
1000
))
np
.
random
.
normal
(
0.1
+
step
*
0.001
,
200.
/
(
100
+
step
),
size
=
1000
))
# create image
# create image
with
logw
.
mode
(
"train"
)
as
logger
:
with
logw
.
mode
(
"train"
)
as
logger
:
image
=
logger
.
image
(
"scratch/dog"
,
4
,
image
=
logger
.
image
(
"scratch/dog"
,
4
,
1
)
# randomly sample 4 images one pass
1
)
# randomly sample 4 images one pass
dog_jpg
=
Image
.
open
(
os
.
path
.
join
(
ROOT
,
'python/dog.jpg'
))
dog_jpg
=
Image
.
open
(
os
.
path
.
join
(
ROOT
,
'python/dog.jpg'
))
dog_jpg
=
dog_jpg
.
resize
(
np
.
array
(
dog_jpg
.
size
)
/
2
)
shape
=
[
dog_jpg
.
size
[
1
],
dog_jpg
.
size
[
0
],
3
]
shape
=
[
dog_jpg
.
size
[
1
],
dog_jpg
.
size
[
0
],
3
]
for
pass_
in
xrange
(
4
):
for
pass_
in
xrange
(
4
):
...
@@ -47,12 +56,13 @@ with logw.mode("train") as logger:
...
@@ -47,12 +56,13 @@ with logw.mode("train") as logger:
right_x
=
left_x
+
target_shape
[
1
]
right_x
=
left_x
+
target_shape
[
1
]
right_y
=
left_y
+
target_shape
[
0
]
right_y
=
left_y
+
target_shape
[
0
]
idx
=
image
.
is_sample_taken
()
# a more efficient way to sample images
# a more efficient way to sample images is
idx
=
image
.
is_sample_taken
()
# check whether this image will be taken by reservoir sampling
if
idx
>=
0
:
if
idx
>=
0
:
data
=
np
.
array
(
data
=
np
.
array
(
dog_jpg
.
crop
((
left_x
,
left_y
,
right_x
,
dog_jpg
.
crop
((
left_x
,
left_y
,
right_x
,
right_y
))).
flatten
()
right_y
))).
flatten
()
# add this image to log
image
.
set_sample
(
idx
,
target_shape
,
data
)
image
.
set_sample
(
idx
,
target_shape
,
data
)
# you can also just write followig codes, it is more clear, but need to
# you can also just write followig codes, it is more clear, but need to
# process image even if it will not be sampled.
# process image even if it will not be sampled.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录