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
07a83a66
Commit
07a83a66
authored
Aug 27, 2019
by
Yong Wu
Committed by
Yao Wang
Aug 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix][Keras] axis of softmax (#3834)
parent
347e3d9d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
python/tvm/relay/frontend/keras.py
+11
-2
tests/python/frontend/keras/test_forward.py
+5
-1
No files found.
python/tvm/relay/frontend/keras.py
View file @
07a83a66
...
...
@@ -117,7 +117,16 @@ def _convert_advanced_activation(inexpr, keras_layer, etab):
act_type
=
type
(
keras_layer
)
.
__name__
if
act_type
==
'Softmax'
:
return
_op
.
nn
.
softmax
(
inexpr
,
axis
=
1
)
axis
=
keras_layer
.
axis
dims
=
len
(
keras_layer
.
input_shape
)
if
isinstance
(
axis
,
list
):
raise
tvm
.
error
.
OpAttributeUnImplemented
(
'Softmax with axes {} is not supported.'
.
format
(
axis
))
if
axis
==
-
1
:
axis
=
1
else
:
axis
=
axis
+
1
if
axis
<
dims
-
1
else
1
return
_op
.
nn
.
softmax
(
inexpr
,
axis
=
axis
)
if
act_type
==
'ReLU'
:
if
keras_layer
.
max_value
:
return
_op
.
clip
(
inexpr
,
a_min
=
0.
,
a_max
=
float
(
keras_layer
.
max_value
))
...
...
@@ -344,7 +353,7 @@ def _convert_pooling(inexpr, keras_layer, etab):
pad_l
,
pad_r
=
_get_pad_pair
(
in_w
,
pool_w
,
stride_w
)
params
[
'padding'
]
=
[
pad_t
,
pad_l
,
pad_b
,
pad_r
]
else
:
raise
tvm
.
error
.
OpAttributeUn
i
mplemented
(
raise
tvm
.
error
.
OpAttributeUn
I
mplemented
(
'Padding with {} is not supported in operator Pooling.'
.
format
(
keras_layer
.
padding
))
if
pool_type
==
'MaxPooling2D'
:
return
_op
.
nn
.
max_pool2d
(
inexpr
,
**
params
)
...
...
tests/python/frontend/keras/test_forward.py
View file @
07a83a66
...
...
@@ -95,6 +95,11 @@ def test_forward_merge():
def
test_forward_activations
():
data
=
keras
.
layers
.
Input
(
shape
=
(
32
,
32
,
3
))
act_funcs
=
[
keras
.
layers
.
Activation
(
'softmax'
),
keras
.
layers
.
Softmax
(),
keras
.
layers
.
Softmax
(
axis
=-
1
),
keras
.
layers
.
Softmax
(
axis
=
1
),
keras
.
layers
.
Softmax
(
axis
=
2
),
keras
.
layers
.
Softmax
(
axis
=
3
),
keras
.
layers
.
Activation
(
'softplus'
),
keras
.
layers
.
Activation
(
'relu'
),
keras
.
layers
.
Activation
(
'softsign'
),
...
...
@@ -103,7 +108,6 @@ def test_forward_activations():
keras
.
layers
.
Activation
(
'tanh'
),
keras
.
layers
.
Activation
(
'linear'
),
keras
.
layers
.
Activation
(
'selu'
),
keras
.
layers
.
Softmax
(),
keras
.
layers
.
ReLU
(),
keras
.
layers
.
ReLU
(
max_value
=
6.
),
keras
.
layers
.
LeakyReLU
(
alpha
=
0.3
),
...
...
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