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
83c3a098
Commit
83c3a098
authored
Jul 27, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
name scope clean-ups in regularization and resnet (#340)
parent
979d18ca
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
23 deletions
+26
-23
examples/ResNet/imagenet_resnet_utils.py
examples/ResNet/imagenet_resnet_utils.py
+17
-15
tensorpack/models/regularize.py
tensorpack/models/regularize.py
+9
-8
No files found.
examples/ResNet/imagenet_resnet_utils.py
View file @
83c3a098
...
@@ -157,6 +157,7 @@ def eval_on_ILSVRC12(model, model_file, dataflow):
...
@@ -157,6 +157,7 @@ def eval_on_ILSVRC12(model, model_file, dataflow):
def
image_preprocess
(
image
,
bgr
=
True
):
def
image_preprocess
(
image
,
bgr
=
True
):
with
tf
.
name_scope
(
'image_preprocess'
):
if
image
.
dtype
.
base_dtype
!=
tf
.
float32
:
if
image
.
dtype
.
base_dtype
!=
tf
.
float32
:
image
=
tf
.
cast
(
image
,
tf
.
float32
)
image
=
tf
.
cast
(
image
,
tf
.
float32
)
image
=
image
*
(
1.0
/
255
)
image
=
image
*
(
1.0
/
255
)
...
@@ -177,8 +178,9 @@ def compute_loss_and_error(logits, label):
...
@@ -177,8 +178,9 @@ def compute_loss_and_error(logits, label):
loss
=
tf
.
reduce_mean
(
loss
,
name
=
'xentropy-loss'
)
loss
=
tf
.
reduce_mean
(
loss
,
name
=
'xentropy-loss'
)
def
prediction_incorrect
(
logits
,
label
,
topk
=
1
,
name
=
'incorrect_vector'
):
def
prediction_incorrect
(
logits
,
label
,
topk
=
1
,
name
=
'incorrect_vector'
):
return
tf
.
cast
(
tf
.
logical_not
(
tf
.
nn
.
in_top_k
(
logits
,
label
,
topk
)),
with
tf
.
name_scope
(
'prediction_incorrect'
):
tf
.
float32
,
name
=
name
)
x
=
tf
.
logical_not
(
tf
.
nn
.
in_top_k
(
logits
,
label
,
topk
))
return
tf
.
cast
(
x
,
tf
.
float32
,
name
=
name
)
wrong
=
prediction_incorrect
(
logits
,
label
,
1
,
name
=
'wrong-top1'
)
wrong
=
prediction_incorrect
(
logits
,
label
,
1
,
name
=
'wrong-top1'
)
add_moving_summary
(
tf
.
reduce_mean
(
wrong
,
name
=
'train-error-top1'
))
add_moving_summary
(
tf
.
reduce_mean
(
wrong
,
name
=
'train-error-top1'
))
...
...
tensorpack/models/regularize.py
View file @
83c3a098
...
@@ -46,6 +46,7 @@ def regularize_cost(regex, func, name='regularize_cost'):
...
@@ -46,6 +46,7 @@ def regularize_cost(regex, func, name='regularize_cost'):
# If vars are replicated, only regularize those in the current tower
# If vars are replicated, only regularize those in the current tower
params
=
ctx
.
filter_vars_by_vs_name
(
params
)
params
=
ctx
.
filter_vars_by_vs_name
(
params
)
with
tf
.
name_scope
(
'regularize_cost'
):
costs
=
[]
costs
=
[]
for
p
in
params
:
for
p
in
params
:
para_name
=
p
.
name
para_name
=
p
.
name
...
...
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