Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
17ba5a44
X
X2Paddle
项目概览
PaddlePaddle
/
X2Paddle
大约 1 年 前同步成功
通知
328
Star
698
Fork
167
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
26
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
X2Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
26
Issue
26
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
17ba5a44
编写于
6月 18, 2019
作者:
S
SunAhong1993
提交者:
GitHub
6月 18, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #29 from SunAhong1993/master
fix the bug of load numpy and fix diff.sh, reshape.py
上级
61b12ed6
9a8cd211
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
12 addition
and
44 deletion
+12
-44
caffe2fluid/examples/imagenet/infer.py
caffe2fluid/examples/imagenet/infer.py
+1
-1
caffe2fluid/examples/imagenet/tools/diff.sh
caffe2fluid/examples/imagenet/tools/diff.sh
+1
-1
caffe2fluid/kaffe/custom_layers/reshape.py
caffe2fluid/kaffe/custom_layers/reshape.py
+5
-40
caffe2fluid/kaffe/paddle/network.py
caffe2fluid/kaffe/paddle/network.py
+2
-2
caffe2fluid/kaffe/shapes.py
caffe2fluid/kaffe/shapes.py
+3
-0
未找到文件。
caffe2fluid/examples/imagenet/infer.py
浏览文件 @
17ba5a44
...
...
@@ -172,7 +172,7 @@ def load_model(exe, place, net_file, net_name, net_weight, debug):
def
get_shape
(
fluid
,
program
,
name
):
for
var
in
program
.
list_vars
():
if
var
.
name
==
'data
'
:
if
var
.
type
==
'Input
'
:
return
list
(
var
.
shape
[
1
:])
raise
ValueError
(
'not found shape for input layer[%s], '
...
...
caffe2fluid/examples/imagenet/tools/diff.sh
浏览文件 @
17ba5a44
...
...
@@ -49,7 +49,7 @@ if [[ -z $PYTHON ]];then
PYTHON
=
`
which python
`
fi
$PYTHON
../../convert.py
\
$proto_file
\
--npy_path
$proto_file
\
--caffemodel
$caffemodel_file
\
--data-output-path
$weight_file
\
--code-output-path
$net_file
...
...
caffe2fluid/kaffe/custom_layers/reshape.py
浏览文件 @
17ba5a44
...
...
@@ -2,6 +2,7 @@
more info can be found here: http://caffe.berkeleyvision.org/tutorial/layers/reshape.html
"""
from
.register
import
register
from
functools
import
reduce
def
import_fluid
():
...
...
@@ -61,43 +62,6 @@ def reshape_shape(input_sp, shape, axis=0, num_axes=-1):
assert
len
(
output_shape
)
==
num_axes_retained
+
num_new_axes
,
\
"[Reshape]invalid dims of output shape[%s]"
%
(
str
(
output_shape
))
inferred_axis
=
-
1
copy_axes
=
[]
constant_count
=
1
for
i
in
range
(
num_new_axes
):
top_dim
=
shape
[
'dim'
][
i
]
if
top_dim
==
0
:
copy_axes
.
append
(
i
)
copy_axis_index
=
start_axis
+
i
output_shape
[
copy_axis_index
]
=
input_shape
[
copy_axis_index
]
elif
top_dim
==
-
1
:
assert
inferred_axis
==
-
1
,
"[Reshape]new shape contains multiple -1 dims"
inferred_axis
=
i
else
:
constant_count
*=
top_dim
if
inferred_axis
>=
0
:
explicit_count
=
constant_count
l
=
input_shape
[
0
:
start_axis
]
if
len
(
l
)
>
0
:
explicit_count
*=
count
(
l
)
l
=
input_shape
[
end_axis
:]
if
len
(
l
)
>
0
:
explicit_count
*=
count
(
l
)
for
i
in
range
(
len
(
copy_axes
)):
explicit_count
*=
output_shape
[
start_axis
+
copy_axes
[
i
]]
assert
input_count
%
explicit_count
==
0
,
"[Reshape]botom count[%d] "
\
"must be divisible by product of the specified dimensions[%d] "
\
%
(
input_count
,
explicit_count
)
output_shape
[
start_axis
+
inferred_axis
]
=
input_count
/
explicit_count
output_count
=
count
(
output_shape
)
assert
output_count
==
input_count
,
"[Reshape]output count[%d] must match input count[%d]"
%
(
output_count
,
input_count
)
return
output_shape
...
...
@@ -117,17 +81,18 @@ def reshape_layer(input, name, shape, axis=0, num_axes=-1):
fluid
=
import_fluid
()
input_shape
=
list
(
input
.
shape
)
print
(
input_shape
)
print
(
shape
)
if
input_shape
[
0
]
==
-
1
:
input_shape
[
0
]
=
1
input_shape
[
0
]
=
0
output_shape
=
reshape_shape
(
input_shape
,
shape
,
axis
,
num_axes
)
output_shape
[
0
]
=
-
1
else
:
output_shape
=
reshape_shape
(
input_shape
,
shape
,
axis
,
num_axes
)
output
=
fluid
.
layers
.
reshape
(
input
,
shape
=
output_shape
,
name
=
name
)
return
output
register
(
kind
=
'Reshape'
,
shape
=
reshape_shape
,
layer
=
reshape_layer
)
caffe2fluid/kaffe/paddle/network.py
浏览文件 @
17ba5a44
...
...
@@ -103,7 +103,7 @@ class Network(object):
place
=
self
.
paddle_env
[
'place'
]
exe
=
self
.
paddle_env
[
'exe'
]
data_dict
=
np
.
load
(
data_path
).
item
()
data_dict
=
np
.
load
(
data_path
,
allow_pickle
=
True
).
item
()
for
op_name
in
data_dict
:
if
op_name
==
'caffe2fluid_name_trace'
:
self
.
name_trace
=
data_dict
[
op_name
]
...
...
@@ -441,7 +441,7 @@ class Network(object):
need_transpose
=
True
if
need_transpose
:
in_order
=
range
(
dims
)
in_order
=
list
(
range
(
dims
)
)
in_order
.
remove
(
axis
)
in_order
.
append
(
axis
)
input
=
fluid
.
layers
.
transpose
(
...
...
caffe2fluid/kaffe/shapes.py
浏览文件 @
17ba5a44
...
...
@@ -3,6 +3,9 @@ from collections import namedtuple
from
.errors
import
KaffeError
Tensor5DShape
=
namedtuple
(
'Tensor5DShape'
,
[
'batch_size'
,
'data1'
,
'daat2'
,
'data3'
,
'data4'
])
Tensor4DShape
=
namedtuple
(
'Tensor4DShape'
,
[
'batch_size'
,
'channels'
,
'height'
,
'width'
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录