提交 20373152 authored 作者: peterjsadowski's avatar peterjsadowski

Fixed pep8 compliance and added test.

上级 930f37e2
......@@ -119,7 +119,7 @@ class Images2Neibs(Op):
Helper function that adds gradient contribution from a single
neighborhood position i,j.
pidx = Index of position within neighborhood.
pgz = Gradient of shape (1, batch_size*num_channels*neibs)
pgz = Gradient of shape (batch_size*num_channels*neibs)
prior_result = Shape (batch_size, num_channnels, rows, cols)
neib_shape = Number of rows, cols in a neighborhood.
neib_step = Step sizes from image2neibs.
......@@ -131,8 +131,8 @@ class Images2Neibs(Op):
j = pidx - (i * ncols)
# This position does not touch some img pixels in valid mode.
result_indices = prior_result[:, :,
i:rows-nrows+i+1:rstep,
j:cols-ncols+j+1:cstep]
i:(rows - nrows + i + 1):rstep,
j:(cols - ncols + j + 1):cstep]
newshape = (batch_size, num_channels) + \
((rows - nrows) // rstep + 1,) + \
((cols - ncols) // cstep + 1,)
......
......@@ -302,6 +302,13 @@ class T_Images2Neibs(unittest_tools.InferShapeTester):
unittest_tools.verify_grad(fn, [images_val], mode=self.mode,
eps=0.1)
def fn(images):
return images2neibs(images, (1, 2), (5, 2))
unittest_tools.verify_grad(fn, [images_val], mode=self.mode,
eps=0.1)
def test_grad_ignore_border(self):
shape = (2, 3, 5, 5)
images_val = numpy.random.rand(*shape).astype('float32')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论