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
b5ff88b0
Commit
b5ff88b0
authored
Jul 13, 2018
by
Siju
Committed by
Tianqi Chen
Jul 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Darknet] softmax temperature in frontend (#1429)
parent
3b476ffe
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
nnvm/python/nnvm/frontend/darknet.py
+5
-0
nnvm/tests/python/frontend/darknet/test_forward.py
+24
-0
No files found.
nnvm/python/nnvm/frontend/darknet.py
View file @
b5ff88b0
...
@@ -260,6 +260,9 @@ def _darknet_reshape(inputs, attrs):
...
@@ -260,6 +260,9 @@ def _darknet_reshape(inputs, attrs):
def
_darknet_softmax_output
(
inputs
,
attrs
):
def
_darknet_softmax_output
(
inputs
,
attrs
):
"""Process the softmax operation."""
"""Process the softmax operation."""
temperature
=
attrs
.
get
(
'temperature'
,
1
)
if
temperature
!=
1
:
inputs
[
0
]
=
inputs
[
0
]
/
float
(
temperature
)
op_name
,
new_attrs
=
'softmax'
,
{}
op_name
,
new_attrs
=
'softmax'
,
{}
if
_darknet_parse_bool_str
(
attrs
,
'multi_output'
):
if
_darknet_parse_bool_str
(
attrs
,
'multi_output'
):
new_attrs
[
'axis'
]
=
1
new_attrs
[
'axis'
]
=
1
...
@@ -529,6 +532,8 @@ def _get_darknet_attrs(net, layer_num):
...
@@ -529,6 +532,8 @@ def _get_darknet_attrs(net, layer_num):
elif
LAYERTYPE
.
SOFTMAX
==
layer
.
type
:
elif
LAYERTYPE
.
SOFTMAX
==
layer
.
type
:
attr
.
update
({
'axis'
:
1
})
attr
.
update
({
'axis'
:
1
})
attr
.
update
({
'use_flatten'
:
True
})
attr
.
update
({
'use_flatten'
:
True
})
if
layer
.
temperature
:
attr
.
update
({
'temperature'
:
str
(
layer
.
temperature
)})
elif
LAYERTYPE
.
SHORTCUT
==
layer
.
type
:
elif
LAYERTYPE
.
SHORTCUT
==
layer
.
type
:
add_layer
=
net
.
layers
[
layer
.
index
]
add_layer
=
net
.
layers
[
layer
.
index
]
...
...
nnvm/tests/python/frontend/darknet/test_forward.py
View file @
b5ff88b0
...
@@ -267,6 +267,28 @@ def test_forward_elu():
...
@@ -267,6 +267,28 @@ def test_forward_elu():
test_forward
(
net
)
test_forward
(
net
)
LIB
.
free_network
(
net
)
LIB
.
free_network
(
net
)
def
test_forward_softmax
():
'''test softmax layer'''
net
=
LIB
.
make_network
(
1
)
layer_1
=
LIB
.
make_softmax_layer
(
1
,
75
,
1
)
layer_1
.
temperature
=
1
net
.
layers
[
0
]
=
layer_1
net
.
w
=
net
.
h
=
5
LIB
.
resize_network
(
net
,
net
.
w
,
net
.
h
)
test_forward
(
net
)
LIB
.
free_network
(
net
)
def
test_forward_softmax_temperature
():
'''test softmax layer'''
net
=
LIB
.
make_network
(
1
)
layer_1
=
LIB
.
make_softmax_layer
(
1
,
75
,
1
)
layer_1
.
temperature
=
0.8
net
.
layers
[
0
]
=
layer_1
net
.
w
=
net
.
h
=
5
LIB
.
resize_network
(
net
,
net
.
w
,
net
.
h
)
test_forward
(
net
)
LIB
.
free_network
(
net
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_forward_resnet50
()
test_forward_resnet50
()
test_forward_alexnet
()
test_forward_alexnet
()
...
@@ -279,6 +301,8 @@ if __name__ == '__main__':
...
@@ -279,6 +301,8 @@ if __name__ == '__main__':
test_forward_shortcut
()
test_forward_shortcut
()
test_forward_dense
()
test_forward_dense
()
test_forward_dense_batchnorm
()
test_forward_dense_batchnorm
()
test_forward_softmax
()
test_forward_softmax_temperature
()
test_forward_reorg
()
test_forward_reorg
()
test_forward_region
()
test_forward_region
()
test_forward_elu
()
test_forward_elu
()
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