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
bc4c68be
Commit
bc4c68be
authored
Apr 14, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix upsample corner interpolation
parent
c43956a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
12 deletions
+11
-12
tensorpack/models/pool.py
tensorpack/models/pool.py
+11
-12
No files found.
tensorpack/models/pool.py
View file @
bc4c68be
...
...
@@ -151,11 +151,6 @@ def BilinearUpSample(x, shape):
Returns:
tf.Tensor: a NHWC tensor.
"""
# inp_shape = tf.shape(x)
# return tf.image.resize_bilinear(x,
# tf.stack([inp_shape[1]*shape,inp_shape[2]*shape]),
# align_corners=True)
inp_shape
=
x
.
get_shape
()
.
as_list
()
ch
=
inp_shape
[
3
]
assert
ch
is
not
None
...
...
@@ -177,12 +172,16 @@ def BilinearUpSample(x, shape):
return
ret
w
=
bilinear_conv_filler
(
filter_shape
)
w
=
np
.
repeat
(
w
,
ch
*
ch
)
.
reshape
((
filter_shape
,
filter_shape
,
ch
,
ch
))
weight_var
=
tf
.
constant
(
w
,
tf
.
float32
,
shape
=
(
filter_shape
,
filter_shape
,
ch
,
ch
),
name
=
'bilinear_upsample_filter'
)
deconv
=
tf
.
nn
.
conv2d_transpose
(
x
,
weight_var
,
tf
.
shape
(
x
)
*
tf
.
constant
([
1
,
shape
,
shape
,
1
],
tf
.
int32
),
x
=
tf
.
pad
(
x
,
[[
0
,
0
],
[
shape
-
1
,
shape
-
1
],
[
shape
-
1
,
shape
-
1
],
[
0
,
0
]],
mode
=
'SYMMETRIC'
)
out_shape
=
tf
.
shape
(
x
)
*
tf
.
constant
([
1
,
shape
,
shape
,
1
],
tf
.
int32
)
deconv
=
tf
.
nn
.
conv2d_transpose
(
x
,
weight_var
,
out_shape
,
[
1
,
shape
,
shape
,
1
],
'SAME'
)
edge
=
shape
*
(
shape
-
1
)
deconv
=
deconv
[:,
edge
:
-
edge
,
edge
:
-
edge
,
:]
if
inp_shape
[
1
]:
inp_shape
[
1
]
*=
shape
...
...
@@ -221,15 +220,15 @@ class TestPool(TestModel):
res
=
self
.
run_variable
(
output
)[
0
,
:,
:,
0
]
from
skimage.transform
import
rescale
res2
=
rescale
(
mat
,
scale
,
mode
=
'
constant
'
)
res2
=
rescale
(
mat
,
scale
,
mode
=
'
edge
'
)
diff
=
np
.
abs
(
res2
-
res
)
# TODO not equivalent to rescale on edge?
diff
[
0
,
:]
=
0
diff
[
-
1
,
:]
=
0
diff
[:,
0
]
=
0
diff
[:,
-
1
]
=
0
#
diff[0, :] = 0
#
diff[-1, :] = 0
#
diff[:, 0] = 0
#
diff[:, -1] = 0
# if not diff.max() < 1e-4:
# import IPython
# IPython.embed(config=IPython.terminal.ipapp.load_default_config())
...
...
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