Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
d752177b
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d752177b
编写于
1月 07, 2019
作者:
S
sneaxiy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enforce_dim_check_in_data_feeder
test=develop
上级
1df2399e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
12 deletion
+13
-12
python/paddle/fluid/data_feeder.py
python/paddle/fluid/data_feeder.py
+13
-12
未找到文件。
python/paddle/fluid/data_feeder.py
浏览文件 @
d752177b
...
@@ -71,10 +71,20 @@ class DataToLoDTensorConverter(object):
...
@@ -71,10 +71,20 @@ class DataToLoDTensorConverter(object):
for
each_data
in
data
:
for
each_data
in
data
:
self
.
_feed_impl_
(
each_data
,
lod
[
1
:],
lod_level
-
1
)
self
.
_feed_impl_
(
each_data
,
lod
[
1
:],
lod_level
-
1
)
def
_check_shape_
(
self
,
shape
):
for
s1
,
s2
in
zip
(
self
.
shape
,
shape
):
if
s1
!=
s2
and
s1
>=
0
and
s2
>=
0
:
raise
ValueError
(
"Shape not match. What is defined in data layer is {}, but receive {}"
.
format
(
self
.
shape
,
shape
))
def
done
(
self
):
def
done
(
self
):
arr
=
numpy
.
array
(
self
.
data
,
dtype
=
self
.
dtype
)
arr
=
numpy
.
array
(
self
.
data
,
dtype
=
self
.
dtype
)
if
self
.
shape
and
len
(
arr
.
shape
)
!=
len
(
self
.
shape
):
if
self
.
shape
:
arr
=
arr
.
reshape
(
self
.
shape
)
if
len
(
arr
.
shape
)
!=
len
(
self
.
shape
):
arr
=
arr
.
reshape
(
self
.
shape
)
else
:
self
.
_check_shape_
(
arr
.
shape
)
t
=
core
.
LoDTensor
()
t
=
core
.
LoDTensor
()
t
.
set
(
arr
,
self
.
place
)
t
.
set
(
arr
,
self
.
place
)
if
self
.
lod_level
>
0
:
if
self
.
lod_level
>
0
:
...
@@ -152,17 +162,8 @@ class DataFeeder(object):
...
@@ -152,17 +162,8 @@ class DataFeeder(object):
raise
TypeError
(
"Feed list should contain a list of variable"
)
raise
TypeError
(
"Feed list should contain a list of variable"
)
self
.
feed_dtypes
.
append
(
each_var
.
dtype
)
self
.
feed_dtypes
.
append
(
each_var
.
dtype
)
self
.
feed_names
.
append
(
each_var
.
name
)
self
.
feed_names
.
append
(
each_var
.
name
)
shape
=
each_var
.
shape
batch_size_dim
=
-
1
for
i
,
s
in
enumerate
(
shape
):
if
s
<
0
:
batch_size_dim
=
i
break
if
batch_size_dim
==
-
1
:
raise
ValueError
(
"Variable {0} must has a batch size dimension"
,
each_var
.
name
)
self
.
feed_lod_level
.
append
(
each_var
.
lod_level
)
self
.
feed_lod_level
.
append
(
each_var
.
lod_level
)
self
.
feed_shapes
.
append
(
shape
)
self
.
feed_shapes
.
append
(
each_var
.
shape
)
self
.
place
=
place
self
.
place
=
place
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录