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
09215019
Commit
09215019
authored
Sep 28, 2017
by
Joshua Z. Zhang
Committed by
Tianqi Chen
May 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TUTORIAL] use resnet v2 (#51)
* use resnet v2 * fix
parent
120753d4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
nnvm/tutorials/from_mxnet.py
+5
-5
No files found.
nnvm/tutorials/from_mxnet.py
View file @
09215019
...
...
@@ -28,7 +28,7 @@ from mxnet.gluon.model_zoo.vision import get_model
from
mxnet.gluon.utils
import
download
import
Image
from
matplotlib
import
pyplot
as
plt
block
=
get_model
(
'resnet18_v
1
'
,
pretrained
=
True
)
block
=
get_model
(
'resnet18_v
2
'
,
pretrained
=
True
)
img_name
=
'cat.jpg'
synset_url
=
''
.
join
([
'https://gist.githubusercontent.com/zhreshold/'
,
'4d0b62f3d01426887599d4f7ede23ee5/raw/'
,
...
...
@@ -85,7 +85,7 @@ m.set_input(**params)
m
.
run
()
# get outputs
tvm_output
=
m
.
get_output
(
0
,
tvm
.
nd
.
empty
((
1000
,),
dtype
))
top1
=
np
.
argmax
(
tvm_output
)
top1
=
np
.
argmax
(
tvm_output
.
asnumpy
()
)
print
(
'TVM prediction top-1:'
,
top1
,
synset
[
top1
])
######################################################################
...
...
@@ -103,12 +103,12 @@ def block2symbol(block):
return
sym
,
args
,
auxs
mx_sym
,
args
,
auxs
=
block2symbol
(
block
)
# usually we would save/load it as checkpoint
mx
.
model
.
save_checkpoint
(
'resnet18_v
1
'
,
0
,
mx_sym
,
args
,
auxs
)
# there are 'resnet18_v
1-0000.params' and 'resnet18_v1
-symbol.json' on disk
mx
.
model
.
save_checkpoint
(
'resnet18_v
2
'
,
0
,
mx_sym
,
args
,
auxs
)
# there are 'resnet18_v
2-0000.params' and 'resnet18_v2
-symbol.json' on disk
######################################################################
# for a normal mxnet model, we start from here
mx_sym
,
args
,
auxs
=
mx
.
model
.
load_checkpoint
(
'resnet18_v
1
'
,
0
)
mx_sym
,
args
,
auxs
=
mx
.
model
.
load_checkpoint
(
'resnet18_v
2
'
,
0
)
# now we use the same API to get NNVM compatible symbol
nnvm_sym
,
nnvm_params
=
nnvm
.
frontend
.
from_mxnet
(
mx_sym
,
args
,
auxs
)
# repeat the same steps to run this model using TVM
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