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
0ec586b0
Commit
0ec586b0
authored
Jul 15, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rect
parent
f1b1ff92
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
4 deletions
+38
-4
examples/Inception/inception-bn.py
examples/Inception/inception-bn.py
+1
-1
tensorpack/tfutils/gradproc.py
tensorpack/tfutils/gradproc.py
+1
-1
tensorpack/utils/rect.py
tensorpack/utils/rect.py
+36
-2
No files found.
examples/Inception/inception-bn.py
View file @
0ec586b0
...
...
@@ -21,7 +21,7 @@ INPUT_SHAPE = 224
Inception-BN model on ILSVRC12.
See "Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift", arxiv:1502.03167
This config reaches 71
%
single-crop validation accuracy after
30
0k steps with 6 TitanX.
This config reaches 71
%
single-crop validation accuracy after
15
0k steps with 6 TitanX.
Learning rate may need a different schedule for different number of GPUs (because batch size will be different).
"""
...
...
tensorpack/tfutils/gradproc.py
View file @
0ec586b0
...
...
@@ -45,7 +45,7 @@ class SummaryGradient(GradientProcessor):
tf
.
histogram_summary
(
name
+
'/grad'
,
grad
)
add_moving_summary
(
tf
.
sqrt
(
tf
.
reduce_mean
(
tf
.
square
(
grad
)),
name
=
name
+
'/
grad
RMS'
))
name
=
name
+
'/RMS'
))
return
grads
...
...
tensorpack/utils/rect.py
View file @
0ec586b0
...
...
@@ -3,6 +3,7 @@
# File: rect.py
# Author: Yuxin Wu <ppwwyyxxc@gmail.com>
import
numpy
as
np
class
Rect
(
object
):
"""
...
...
@@ -11,12 +12,13 @@ class Rect(object):
"""
__slots__
=
[
'x'
,
'y'
,
'w'
,
'h'
]
def
__init__
(
self
,
x
=
0
,
y
=
0
,
w
=
0
,
h
=
0
):
def
__init__
(
self
,
x
=
0
,
y
=
0
,
w
=
0
,
h
=
0
,
allow_neg
=
False
):
self
.
x
=
x
self
.
y
=
y
self
.
w
=
w
self
.
h
=
h
assert
min
(
self
.
x
,
self
.
y
,
self
.
w
,
self
.
h
)
>=
0
if
not
allow_neg
:
assert
min
(
self
.
x
,
self
.
y
,
self
.
w
,
self
.
h
)
>=
0
@
property
def
x0
(
self
):
...
...
@@ -68,4 +70,36 @@ class Rect(object):
assert
self
.
validate
(
img
.
shape
[:
2
])
return
img
[
self
.
y0
:
self
.
y1
+
1
,
self
.
x0
:
self
.
x1
+
1
]
def
expand
(
self
,
frac
):
neww
=
self
.
w
*
frac
newh
=
self
.
h
*
frac
newx
=
self
.
x
-
(
neww
-
self
.
w
)
*
0.5
newy
=
self
.
y
-
(
newh
-
self
.
h
)
*
0.5
return
Rect
(
*
(
map
(
int
,
[
newx
,
newy
,
neww
,
newh
])),
allow_neg
=
True
)
def
roi_zeropad
(
self
,
img
):
shp
=
list
(
img
.
shape
)
shp
[
0
]
=
self
.
h
shp
[
1
]
=
self
.
w
ret
=
np
.
zeros
(
tuple
(
shp
),
dtype
=
img
.
dtype
)
xstart
=
0
if
self
.
x
>=
0
else
-
self
.
x
ystart
=
0
if
self
.
y
>=
0
else
-
self
.
y
xmin
=
max
(
self
.
x0
,
0
)
ymin
=
max
(
self
.
y0
,
0
)
xmax
=
min
(
self
.
x1
,
img
.
shape
[
1
])
ymax
=
min
(
self
.
y1
,
img
.
shape
[
0
])
patch
=
img
[
ymin
:
ymax
,
xmin
:
xmax
]
ret
[
ystart
:
ystart
+
patch
.
shape
[
0
],
xstart
:
xstart
+
patch
.
shape
[
1
]]
=
patch
return
ret
__repr__
=
__str__
if
__name__
==
'__main__'
:
x
=
Rect
(
2
,
1
,
3
,
3
,
allow_neg
=
True
)
img
=
np
.
random
.
rand
(
3
,
3
)
print
img
print
x
.
roi_zeropad
(
img
)
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