Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
c68945c5
Commit
c68945c5
authored
May 25, 2018
by
MORITA Kazutaka
Committed by
Tianqi Chen
May 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FRONTEND][Keras] fix reshape (#493)
parent
39cc9c12
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
5 deletions
+15
-5
nnvm/python/nnvm/frontend/keras.py
+6
-5
nnvm/tests/python/frontend/keras/test_forward.py
+9
-0
No files found.
nnvm/python/nnvm/frontend/keras.py
View file @
c68945c5
...
@@ -345,11 +345,12 @@ def _convert_concat(insym, keras_layer, _):
...
@@ -345,11 +345,12 @@ def _convert_concat(insym, keras_layer, _):
def
_convert_reshape
(
insym
,
keras_layer
,
_
):
def
_convert_reshape
(
insym
,
keras_layer
,
_
):
shape
=
keras_layer
.
shape
if
hasattr
(
keras_layer
,
'shape'
)
\
_check_data_format
(
keras_layer
)
else
keras_layer
.
target_shape
if
hasattr
(
keras_layer
,
'target_shape'
)
\
ch
=
keras_layer
.
input_shape
[
-
1
]
else
None
assert
ch
==
keras_layer
.
target_shape
[
-
1
],
\
if
shape
is
None
:
"Only supports last dimension in target shape being equal to "
\
raise
TypeError
(
"No shape attribute in reshape layer: {}"
.
format
(
keras_layer
))
"the channel number of input tensor."
shape
=
(
-
1
,
ch
)
+
keras_layer
.
target_shape
[:
-
1
]
return
_sym
.
reshape
(
insym
,
shape
=
shape
)
return
_sym
.
reshape
(
insym
,
shape
=
shape
)
...
...
nnvm/tests/python/frontend/keras/test_forward.py
View file @
c68945c5
...
@@ -134,6 +134,14 @@ def test_forward_relu6():
...
@@ -134,6 +134,14 @@ def test_forward_relu6():
verify_keras_frontend
(
keras_model
)
verify_keras_frontend
(
keras_model
)
def
test_forward_reshape
():
data
=
keras
.
layers
.
Input
(
shape
=
(
32
,
32
,
3
))
x
=
keras
.
layers
.
Reshape
(
target_shape
=
(
32
,
32
,
3
))(
data
)
x
=
keras
.
layers
.
GlobalAveragePooling2D
()(
x
)
keras_model
=
keras
.
models
.
Model
(
data
,
x
)
verify_keras_frontend
(
keras_model
)
def
test_forward_vgg16
():
def
test_forward_vgg16
():
keras_model
=
keras
.
applications
.
vgg16
.
VGG16
(
include_top
=
True
,
weights
=
None
,
keras_model
=
keras
.
applications
.
vgg16
.
VGG16
(
include_top
=
True
,
weights
=
None
,
input_shape
=
(
224
,
224
,
3
),
classes
=
1000
)
input_shape
=
(
224
,
224
,
3
),
classes
=
1000
)
...
@@ -162,6 +170,7 @@ if __name__ == '__main__':
...
@@ -162,6 +170,7 @@ if __name__ == '__main__':
test_forward_separable_conv
()
test_forward_separable_conv
()
test_forward_upsample
()
test_forward_upsample
()
test_forward_relu6
()
test_forward_relu6
()
test_forward_reshape
()
test_forward_vgg16
()
test_forward_vgg16
()
test_forward_xception
()
test_forward_xception
()
...
...
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