Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
da8106ef
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
da8106ef
编写于
2月 21, 2017
作者:
L
Luo Tao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into seqconcat
上级
f9eddadb
037e0a06
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
10 addition
and
3 deletion
+10
-3
demo/sentiment/dataprovider.py
demo/sentiment/dataprovider.py
+2
-0
demo/sentiment/predict.py
demo/sentiment/predict.py
+5
-1
doc/design/reader/README.md
doc/design/reader/README.md
+3
-2
未找到文件。
demo/sentiment/dataprovider.py
浏览文件 @
da8106ef
...
...
@@ -32,4 +32,6 @@ def process(settings, file_name):
word_slot
=
[
settings
.
word_dict
[
w
]
for
w
in
words
if
w
in
settings
.
word_dict
]
if
not
word_slot
:
continue
yield
word_slot
,
label
demo/sentiment/predict.py
浏览文件 @
da8106ef
...
...
@@ -138,7 +138,11 @@ def main():
batch
=
[]
for
line
in
sys
.
stdin
:
batch
.
append
([
predict
.
get_index
(
line
)])
words
=
predict
.
get_index
(
line
)
if
words
:
batch
.
append
([
words
])
else
:
print
(
'All the words in [%s] are not in the dictionary.'
%
line
)
if
len
(
batch
)
==
batch_size
:
predict
.
batch_predict
(
batch
)
batch
=
[]
...
...
doc/design/reader/README.md
浏览文件 @
da8106ef
...
...
@@ -107,7 +107,7 @@ We decided to use dictionary (`{"image":0, "label":1}`) instead of list (`["imag
### How to create custom data reader
```
python
def
image_reader
(
image_path
,
label_path
):
def
image_reader
(
image_path
,
label_path
,
n
):
f
=
open
(
image_path
)
l
=
open
(
label_path
)
images
=
numpy
.
fromfile
(
...
...
@@ -117,9 +117,10 @@ def image_reader(image_path, label_path):
for
i
in
xrange
(
n
):
yield
images
[
i
,
:],
labels
[
i
]
# a single entry of data is created each time
f
.
close
()
l
.
close
()
# use python lambda to change image_reader into a function with no parameters.
reader
=
lambda
:
image_reader
(
"/path/to/image_file"
,
"/path/to/label_file"
)
reader
=
lambda
:
image_reader
(
"/path/to/image_file"
,
"/path/to/label_file"
,
1024
)
paddle
.
train
(
reader
,
{
"image"
:
0
,
"label"
:
1
},
...)
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录