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
0deff876
Commit
0deff876
authored
Sep 27, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a better bilinear upsample
parent
9ec5ca49
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
tensorpack/models/pool.py
tensorpack/models/pool.py
+8
-11
No files found.
tensorpack/models/pool.py
View file @
0deff876
...
@@ -137,20 +137,17 @@ def BilinearUpSample(x, shape):
...
@@ -137,20 +137,17 @@ def BilinearUpSample(x, shape):
return
ret
return
ret
ch
=
x
.
get_shape
()
.
as_list
()[
3
]
ch
=
x
.
get_shape
()
.
as_list
()[
3
]
shape
=
int
(
shape
)
unpool_mat
=
np
.
zeros
((
shape
,
shape
),
dtype
=
'float32'
)
unpool_mat
[
-
1
,
-
1
]
=
1
x
=
FixedUnPooling
(
'unpool'
,
x
,
shape
,
unpool_mat
)
shape
=
int
(
shape
)
filter_shape
=
2
*
shape
filter_shape
=
2
*
shape
w
=
bilinear_conv_filler
(
filter_shape
)
w
=
bilinear_conv_filler
(
filter_shape
)
w
=
np
.
repeat
(
w
,
ch
*
ch
)
.
reshape
((
filter_shape
,
filter_shape
,
ch
,
ch
))
w
=
np
.
repeat
(
w
,
ch
*
ch
)
.
reshape
((
filter_shape
,
filter_shape
,
ch
,
ch
))
weight_var
=
tf
.
constant
(
w
,
weight_var
=
tf
.
constant
(
w
,
tf
.
float32
,
tf
.
float32
,
shape
=
(
filter_shape
,
filter_shape
,
ch
,
ch
))
shape
=
(
filter_shape
,
filter_shape
,
ch
,
ch
))
return
tf
.
nn
.
conv2d_transpose
(
x
,
weight_var
,
tf
.
shape
(
x
)
*
tf
.
constant
([
1
,
shape
,
shape
,
1
],
tf
.
int32
),
[
1
,
shape
,
shape
,
1
],
'SAME'
)
output
=
tf
.
nn
.
conv2d
(
x
,
weight_var
,
[
1
,
1
,
1
,
1
],
padding
=
'SAME'
)
return
output
from
._test
import
TestModel
from
._test
import
TestModel
class
TestPool
(
TestModel
):
class
TestPool
(
TestModel
):
...
@@ -179,14 +176,14 @@ class TestPool(TestModel):
...
@@ -179,14 +176,14 @@ class TestPool(TestModel):
inp
=
tf
.
reshape
(
inp
,
[
1
,
h
,
w
,
1
])
inp
=
tf
.
reshape
(
inp
,
[
1
,
h
,
w
,
1
])
output
=
BilinearUpSample
(
'upsample'
,
inp
,
scale
)
output
=
BilinearUpSample
(
'upsample'
,
inp
,
scale
)
res
=
self
.
run_variable
(
output
)
res
=
self
.
run_variable
(
output
)
[
0
,:,:,
0
]
from
skimage.transform
import
rescale
from
skimage.transform
import
rescale
res2
=
rescale
(
mat
,
scale
)
res2
=
rescale
(
mat
,
scale
)
diff
=
np
.
abs
(
res2
-
res
[
0
,:,:,
0
]
)
diff
=
np
.
abs
(
res2
-
res
)
# not equivalent to rescale on edge
# not equivalent to rescale on edge
?
diff
[
0
,:]
=
0
diff
[
0
,:]
=
0
diff
[:,
0
]
=
0
diff
[:,
0
]
=
0
if
not
diff
.
max
()
<
1e-4
:
if
not
diff
.
max
()
<
1e-4
:
...
...
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