Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
f9bf5407
Commit
f9bf5407
authored
Apr 02, 2019
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ResNeXt for ImageNet
parent
d48cce3a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
3 deletions
+15
-3
examples/ResNet/README.md
examples/ResNet/README.md
+1
-0
examples/ResNet/imagenet-resnet.py
examples/ResNet/imagenet-resnet.py
+5
-3
examples/ResNet/resnet_model.py
examples/ResNet/resnet_model.py
+9
-0
No files found.
examples/ResNet/README.md
View file @
f9bf5407
...
...
@@ -22,6 +22,7 @@ baseline and they actually cannot beat this ResNet recipe.
| ResNet50 | 6.85% | 23.61% |
[
:arrow_down:
](
http://models.tensorpack.com/ResNet/ImageNet-ResNet50.npz
)
|
| ResNet50-SE | 6.24% | 22.64% |
[
:arrow_down:
](
http://models.tensorpack.com/ResNet/ImageNet-ResNet50-SE.npz
)
|
| ResNet101 | 6.04% | 21.95% |
[
:arrow_down:
](
http://models.tensorpack.com/ResNet/ImageNet-ResNet101.npz
)
|
| ResNeXt101-32x4d | 5.73% | 21.05% |
[
:arrow_down:
](
http://models.tensorpack.com/ResNet/ImageNet-ResNeXt101-32x4d.npz
)
|
| ResNet152 | 5.78% | 21.51% |
[
:arrow_down:
](
http://models.tensorpack.com/ResNet/ImageNet-ResNet152.npz
)
|
To reproduce the above results,
...
...
examples/ResNet/imagenet-resnet.py
View file @
f9bf5407
...
...
@@ -15,8 +15,9 @@ from tensorpack.utils.gpu import get_num_gpu
from
imagenet_utils
import
ImageNetModel
,
eval_on_ILSVRC12
,
get_imagenet_dataflow
,
get_imagenet_tfdata
from
resnet_model
import
(
preresnet_basicblock
,
preresnet_bottleneck
,
preresnet_group
,
resnet_backbone
,
resnet_basicblock
,
resnet_bottleneck
,
resnet_group
,
se_resnet_bottleneck
)
preresnet_basicblock
,
preresnet_bottleneck
,
preresnet_group
,
resnet_backbone
,
resnet_group
,
resnet_basicblock
,
resnet_bottleneck
,
resnext_32x4d_bottleneck
,
se_resnet_bottleneck
)
class
Model
(
ImageNetModel
):
...
...
@@ -28,6 +29,7 @@ class Model(ImageNetModel):
basicblock
=
preresnet_basicblock
if
mode
==
'preact'
else
resnet_basicblock
bottleneck
=
{
'resnet'
:
resnet_bottleneck
,
'resnext32x4d'
:
resnext_32x4d_bottleneck
,
'preact'
:
preresnet_bottleneck
,
'se'
:
se_resnet_bottleneck
}[
mode
]
self
.
num_blocks
,
self
.
block_func
=
{
...
...
@@ -126,7 +128,7 @@ if __name__ == '__main__':
help
=
"total batch size. "
"Note that it's best to keep per-GPU batch size in [32, 64] to obtain the best accuracy."
"Pretrained models listed in README were trained with batch=32x8."
)
parser
.
add_argument
(
'--mode'
,
choices
=
[
'resnet'
,
'preact'
,
'se'
],
parser
.
add_argument
(
'--mode'
,
choices
=
[
'resnet'
,
'preact'
,
'se'
,
'resnext32x4d'
],
help
=
'variants of resnet to use'
,
default
=
'resnet'
)
args
=
parser
.
parse_args
()
...
...
examples/ResNet/resnet_model.py
View file @
f9bf5407
...
...
@@ -102,6 +102,15 @@ def se_resnet_bottleneck(l, ch_out, stride):
return
tf
.
nn
.
relu
(
out
)
def
resnext_32x4d_bottleneck
(
l
,
ch_out
,
stride
):
shortcut
=
l
l
=
Conv2D
(
'conv1'
,
l
,
ch_out
*
2
,
1
,
strides
=
1
,
activation
=
BNReLU
)
l
=
Conv2D
(
'conv2'
,
l
,
ch_out
*
2
,
3
,
strides
=
stride
,
activation
=
BNReLU
,
split
=
32
)
l
=
Conv2D
(
'conv3'
,
l
,
ch_out
*
4
,
1
,
activation
=
get_bn
(
zero_init
=
True
))
out
=
l
+
resnet_shortcut
(
shortcut
,
ch_out
*
4
,
stride
,
activation
=
get_bn
(
zero_init
=
False
))
return
tf
.
nn
.
relu
(
out
)
def
resnet_group
(
name
,
l
,
block_func
,
features
,
count
,
stride
):
with
tf
.
variable_scope
(
name
):
for
i
in
range
(
0
,
count
):
...
...
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