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
1188b56d
Commit
1188b56d
authored
Nov 07, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix resnet training
parent
efbf256e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
26 deletions
+24
-26
examples/ResNet/imagenet-resnet.py
examples/ResNet/imagenet-resnet.py
+24
-26
No files found.
examples/ResNet/imagenet-resnet.py
View file @
1188b56d
...
...
@@ -93,7 +93,7 @@ class Model(ModelDesc):
50
:
([
3
,
4
,
6
,
3
],
bottleneck
),
101
:
([
3
,
4
,
23
,
3
],
bottleneck
)
}
defs
,
block_func
=
cfg
[
50
]
defs
,
block_func
=
cfg
[
34
]
with
argscope
(
Conv2D
,
nl
=
tf
.
identity
,
use_bias
=
False
,
W_init
=
variance_scaling_initializer
(
mode
=
'FAN_OUT'
)):
...
...
@@ -119,8 +119,7 @@ class Model(ModelDesc):
add_moving_summary
(
tf
.
reduce_mean
(
wrong
,
name
=
'train-error-top5'
))
# weight decay on all W of fc layers
wd_w
=
tf
.
train
.
exponential_decay
(
1e-4
,
get_global_step_var
(),
200000
,
0.7
,
True
)
wd_w
=
1e-4
wd_cost
=
tf
.
mul
(
wd_w
,
regularize_cost
(
'.*/W'
,
tf
.
nn
.
l2_loss
),
name
=
'l2_regularize_loss'
)
add_moving_summary
(
loss
,
wd_cost
)
self
.
cost
=
tf
.
add_n
([
loss
,
wd_cost
],
name
=
'cost'
)
...
...
@@ -135,7 +134,8 @@ def get_data(train_or_test):
image_std
=
np
.
array
([
0.229
,
0.224
,
0.225
],
dtype
=
'float32'
)
if
isTrain
:
def
resize_func
(
img
):
class
Resize
(
imgaug
.
ImageAugmentor
):
def
_augment
(
self
,
img
,
_
):
# crop 8%~100% of the original image
# See `Going Deeper with Convolutions` by Google.
h
,
w
=
img
.
shape
[:
2
]
...
...
@@ -157,7 +157,7 @@ def get_data(train_or_test):
return
out
augmentors
=
[
imgaug
.
MapImage
(
resize_func
),
Resize
(
),
imgaug
.
RandomOrderAug
(
[
imgaug
.
Brightness
(
30
,
clip
=
False
),
imgaug
.
Contrast
((
0.8
,
1.2
),
clip
=
False
),
...
...
@@ -228,8 +228,6 @@ def eval_on_ILSVRC12(model_file, data_dir):
acc5
.
feed
(
o
[
1
]
.
sum
(),
batch_size
)
print
(
"Top1 Error: {}"
.
format
(
acc1
.
ratio
))
print
(
"Top5 Error: {}"
.
format
(
acc5
.
ratio
))
print
(
"Top1 Error: {}"
.
format
(
acc1
.
ratio
))
print
(
"Top5 Error: {}"
.
format
(
acc5
.
ratio
))
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
()
...
...
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