Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Cresson Remi
otbtf
Commits
2707a129
Commit
2707a129
authored
May 26, 2020
by
Cresson Remi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: migrade python codes from TF1.X --> TF2.X
parent
8cc0e197
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
5 deletions
+2
-5
python/create_savedmodel_pxs_fcn.py
python/create_savedmodel_pxs_fcn.py
+2
-4
python/tricks.py
python/tricks.py
+0
-1
No files found.
python/create_savedmodel_pxs_fcn.py
View file @
2707a129
...
...
@@ -53,8 +53,7 @@ def my_model(x1, x2):
activation
=
tf
.
nn
.
relu
)
# out size: 1x1x64
# Stack features
features
=
tf
.
reshape
(
tf
.
stack
([
conv3_x1
,
conv4_x2
],
axis
=
3
),
shape
=
[
-
1
,
128
],
name
=
"features"
)
features
=
tf
.
reshape
(
tf
.
stack
([
conv3_x1
,
conv4_x2
],
axis
=
3
),
shape
=
[
-
1
,
128
],
name
=
"features"
)
# 8 neurons for 8 classes
estimated
=
tf
.
compat
.
v1
.
layers
.
dense
(
inputs
=
features
,
units
=
params
.
nclasses
,
activation
=
None
)
...
...
@@ -69,8 +68,7 @@ with tf.compat.v1.Graph().as_default():
x1
=
tf
.
compat
.
v1
.
placeholder
(
tf
.
float32
,
[
None
,
None
,
None
,
4
],
name
=
"x1"
)
x2
=
tf
.
compat
.
v1
.
placeholder
(
tf
.
float32
,
[
None
,
None
,
None
,
1
],
name
=
"x2"
)
y
=
tf
.
compat
.
v1
.
placeholder
(
tf
.
int32
,
[
None
,
None
,
None
,
1
],
name
=
"y"
)
lr
=
tf
.
compat
.
v1
.
placeholder_with_default
(
tf
.
constant
(
0.0002
,
dtype
=
tf
.
float32
,
shape
=
[]),
shape
=
[],
name
=
"lr"
)
lr
=
tf
.
compat
.
v1
.
placeholder_with_default
(
tf
.
constant
(
0.0002
,
dtype
=
tf
.
float32
,
shape
=
[]),
shape
=
[],
name
=
"lr"
)
# Output
y_estimated
,
y_label
=
my_model
(
x1
,
x2
)
...
...
python/tricks.py
View file @
2707a129
...
...
@@ -71,7 +71,6 @@ def create_savedmodel(sess, inputs, outputs, directory):
outputs_names
=
{
o
:
graph
.
get_tensor_by_name
(
o
)
for
o
in
outputs
}
tf
.
compat
.
v1
.
saved_model
.
simple_save
(
sess
,
directory
,
inputs
=
inputs_names
,
outputs
=
outputs_names
)
def
ckpt_to_savedmodel
(
ckpt_path
,
inputs
,
outputs
,
savedmodel_path
,
clear_devices
=
False
):
"""
Read a Checkpoint and build a SavedModel
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment