Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
da8106ef
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
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):
...
@@ -32,4 +32,6 @@ def process(settings, file_name):
word_slot
=
[
word_slot
=
[
settings
.
word_dict
[
w
]
for
w
in
words
if
w
in
settings
.
word_dict
settings
.
word_dict
[
w
]
for
w
in
words
if
w
in
settings
.
word_dict
]
]
if
not
word_slot
:
continue
yield
word_slot
,
label
yield
word_slot
,
label
demo/sentiment/predict.py
浏览文件 @
da8106ef
...
@@ -138,7 +138,11 @@ def main():
...
@@ -138,7 +138,11 @@ def main():
batch
=
[]
batch
=
[]
for
line
in
sys
.
stdin
:
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
:
if
len
(
batch
)
==
batch_size
:
predict
.
batch_predict
(
batch
)
predict
.
batch_predict
(
batch
)
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
...
@@ -107,7 +107,7 @@ We decided to use dictionary (`{"image":0, "label":1}`) instead of list (`["imag
### How to create custom data reader
### How to create custom data reader
```
python
```
python
def
image_reader
(
image_path
,
label_path
):
def
image_reader
(
image_path
,
label_path
,
n
):
f
=
open
(
image_path
)
f
=
open
(
image_path
)
l
=
open
(
label_path
)
l
=
open
(
label_path
)
images
=
numpy
.
fromfile
(
images
=
numpy
.
fromfile
(
...
@@ -117,9 +117,10 @@ def image_reader(image_path, label_path):
...
@@ -117,9 +117,10 @@ def image_reader(image_path, label_path):
for
i
in
xrange
(
n
):
for
i
in
xrange
(
n
):
yield
images
[
i
,
:],
labels
[
i
]
# a single entry of data is created each time
yield
images
[
i
,
:],
labels
[
i
]
# a single entry of data is created each time
f
.
close
()
f
.
close
()
l
.
close
()
# use python lambda to change image_reader into a function with no parameters.
# 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
},
...)
paddle
.
train
(
reader
,
{
"image"
:
0
,
"label"
:
1
},
...)
```
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录