Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
394814e8
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看板
提交
394814e8
编写于
8月 05, 2019
作者:
J
jiangjiajun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
little modify
上级
d2340215
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
8 addition
and
33 deletion
+8
-33
x2paddle/core/util.py
x2paddle/core/util.py
+0
-6
x2paddle/decoder/tf_decoder.py
x2paddle/decoder/tf_decoder.py
+8
-27
未找到文件。
x2paddle/core/util.py
浏览文件 @
394814e8
...
@@ -38,9 +38,3 @@ def run_net(param_dir="./"):
...
@@ -38,9 +38,3 @@ def run_net(param_dir="./"):
param_dir
,
param_dir
,
fluid
.
default_main_program
(),
fluid
.
default_main_program
(),
predicate
=
if_exist
)
predicate
=
if_exist
)
fluid
.
io
.
save_inference_model
(
dirname
=
'inference_model'
,
feeded_var_names
=
[
i
.
name
for
i
in
inputs
],
target_vars
=
outputs
,
executor
=
exe
,
params_filename
=
"__params__"
)
x2paddle/decoder/tf_decoder.py
浏览文件 @
394814e8
#coding:utf-8
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License"
# Licensed under the Apache License, Version 2.0 (the "License"
...
@@ -181,24 +182,6 @@ class TFGraph(Graph):
...
@@ -181,24 +182,6 @@ class TFGraph(Graph):
self
.
identity_map
[
node_name
]
=
input_node
.
layer_name
self
.
identity_map
[
node_name
]
=
input_node
.
layer_name
# node = self.get_node(node_name)
# # Remind: Only 1 input for Identity node
# input_node = self.get_node(node.inputs[0])
#
# # remove identity node from graph
# self.identity_map[node_name] = input_node.layer_name
# idx = input_node.outputs.index(node_name)
# del input_node.outputs[idx]
#
# output_names = node.outputs
# for output_name in output_names:
# output_node = self.get_node(output_name)
# idx = output_node.inputs.index(node_name)
# output_node.inputs[idx] = input_node.layer_name
#
# idx = self.topo_sort.index(node_name)
# del self.topo_sort[idx]
if
node_name
in
self
.
output_nodes
:
if
node_name
in
self
.
output_nodes
:
idx
=
self
.
output_nodes
.
index
(
node_name
)
idx
=
self
.
output_nodes
.
index
(
node_name
)
self
.
output_nodes
[
idx
]
=
input_node
.
layer_name
self
.
output_nodes
[
idx
]
=
input_node
.
layer_name
...
@@ -227,10 +210,6 @@ class TFDecoder(object):
...
@@ -227,10 +210,6 @@ class TFDecoder(object):
self
.
sess
.
graph
.
as_default
()
self
.
sess
.
graph
.
as_default
()
tf
.
import_graph_def
(
graph_def
,
name
=
''
,
input_map
=
input_map
)
tf
.
import_graph_def
(
graph_def
,
name
=
''
,
input_map
=
input_map
)
# for node in graph_def.node:
# print(node.name, node.op, node.input)
self
.
sess
.
run
(
tf
.
global_variables_initializer
())
self
.
sess
.
run
(
tf
.
global_variables_initializer
())
self
.
tf_graph
=
TFGraph
(
self
.
tf_graph
=
TFGraph
(
...
@@ -264,13 +243,17 @@ class TFDecoder(object):
...
@@ -264,13 +243,17 @@ class TFDecoder(object):
if
need_define_shape
>
0
:
if
need_define_shape
>
0
:
if
need_define_shape
==
1
:
if
need_define_shape
==
1
:
print
(
print
(
"无法获取到输入结点
\"
{}
\"
的shape"
.
format
(
layer
.
name
))
"
\n
Unknown shape for input tensor[tensor name:
\"
{}
\"
]"
.
print
(
"
Unknown shape for input tensor[tensor name:
\"
{}
\"
]"
.
format
(
layer
.
name
))
format
(
layer
.
name
))
else
:
else
:
print
(
"输入结点
\"
{}
\"
的shape为{},但我们现仅支持batch维为不定长,所以需要你重新设定shape"
.
format
(
layer
.
name
,
shape
))
print
(
print
(
"
\n
Shape[now is {}] for input tensor[tensor name:
\"
{}
\"
] not support yet"
"
\n
Shape[now is {}] for input tensor[tensor name:
\"
{}
\"
] not support yet"
.
format
(
shape
,
layer
.
name
))
.
format
(
shape
,
layer
.
name
))
print
(
"需要你手动在下面输入对应这个输入结点的shape:)"
)
print
(
print
(
"Use your keyboard type the shape of input tensor below :)"
)
"Use your keyboard type the shape of input tensor below :)"
)
...
@@ -293,13 +276,11 @@ class TFDecoder(object):
...
@@ -293,13 +276,11 @@ class TFDecoder(object):
layer
.
name
))
layer
.
name
))
input_map
[
"{}:0"
.
format
(
layer
.
name
)]
=
x2paddle_input
input_map
[
"{}:0"
.
format
(
layer
.
name
)]
=
x2paddle_input
shape
[
shape
.
index
(
None
)]
=
-
1
shape
[
shape
.
index
(
None
)]
=
-
1
# self.input_example_data["x2paddle_{}".format(layer.name)] = numpy.random.random_sample(shape).astype(dtype)
self
.
input_info
[
"x2paddle_{}"
.
format
(
layer
.
name
)]
=
(
shape
,
self
.
input_info
[
"x2paddle_{}"
.
format
(
layer
.
name
)]
=
(
shape
,
dtype
)
dtype
)
else
:
else
:
value
=
graph_node
.
layer
.
attr
[
"shape"
].
shape
value
=
graph_node
.
layer
.
attr
[
"shape"
].
shape
shape
=
[
dim
.
size
for
dim
in
value
.
dim
]
shape
=
[
dim
.
size
for
dim
in
value
.
dim
]
# self.input_example_data[graph_node.layer_name] = numpy.random.random_sample(shape).astype(dtype)
self
.
input_info
[
graph_node
.
layer_name
]
=
(
shape
,
dtype
)
self
.
input_info
[
graph_node
.
layer_name
]
=
(
shape
,
dtype
)
return
input_map
return
input_map
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录