提交 33551a31 authored 作者: Li's avatar Li

grad still not working

上级 218c02f9
...@@ -100,6 +100,9 @@ class DownsampleFactorMax(Op): ...@@ -100,6 +100,9 @@ class DownsampleFactorMax(Op):
extra row/col of partial downsampling (False) or ignore it (True). extra row/col of partial downsampling (False) or ignore it (True).
:type ignore_border: bool :type ignore_border: bool
:param padding: pad zeros on four borders of the images
:type padding: tuple of two ints
:rtype: list :rtype: list
:returns: the shape of the output from this op, for input of given :returns: the shape of the output from this op, for input of given
shape. This will have the same length as imgshape, but with last shape. This will have the same length as imgshape, but with last
...@@ -167,6 +170,9 @@ class DownsampleFactorMax(Op): ...@@ -167,6 +170,9 @@ class DownsampleFactorMax(Op):
(no overlap on pooling regions) (no overlap on pooling regions)
: type st: list or tuple of two ints : type st: list or tuple of two ints
:param padding: pad zeros on four borders of the images
:type padding: tuple of two ints
""" """
self.ds = tuple(ds) self.ds = tuple(ds)
if not all([isinstance(d, int) for d in ds]): if not all([isinstance(d, int) for d in ds]):
...@@ -221,8 +227,8 @@ class DownsampleFactorMax(Op): ...@@ -221,8 +227,8 @@ class DownsampleFactorMax(Op):
pad_w = self.padding[1] pad_w = self.padding[1]
# pad the image # pad the image
fill = x.min()-1 fill = x.min()-1.
y = numpy.zeros((x.shape[0], x.shape[1], img_rows, img_cols)) + fill y = numpy.zeros((x.shape[0], x.shape[1], img_rows, img_cols), dtype=x.dtype) + fill
y[:, :, pad_h:(img_rows-pad_h), pad_w:(img_cols-pad_w)] = x y[:, :, pad_h:(img_rows-pad_h), pad_w:(img_cols-pad_w)] = x
# max pooling # max pooling
for n in xrange(x.shape[0]): for n in xrange(x.shape[0]):
...@@ -332,7 +338,7 @@ class DownsampleFactorMax(Op): ...@@ -332,7 +338,7 @@ class DownsampleFactorMax(Op):
class DownsampleFactorMaxGrad(Op): class DownsampleFactorMaxGrad(Op):
__props__ = ('ds', 'ignore_border', 'st') __props__ = ('ds', 'ignore_border', 'st', 'padding')
def __init__(self, ds, ignore_border, st=None, padding=(0,0)): def __init__(self, ds, ignore_border, st=None, padding=(0,0)):
self.ds = tuple(ds) self.ds = tuple(ds)
...@@ -343,7 +349,7 @@ class DownsampleFactorMaxGrad(Op): ...@@ -343,7 +349,7 @@ class DownsampleFactorMaxGrad(Op):
self.padding = tuple(padding) self.padding = tuple(padding)
def __str__(self): def __str__(self):
return '%s{%s,%s,%s,%s}' % (self.__class__.__name__, return '%s{%s, %s, %s, %s}' % (self.__class__.__name__,
self.ds, self.st, self.ignore_border,self.padding) self.ds, self.st, self.ignore_border,self.padding)
def make_node(self, x, maxout, gz): def make_node(self, x, maxout, gz):
...@@ -373,7 +379,7 @@ class DownsampleFactorMaxGrad(Op): ...@@ -373,7 +379,7 @@ class DownsampleFactorMaxGrad(Op):
# pad the image # pad the image
fill = x.min()-1 fill = x.min()-1
y = numpy.zeros((x.shape[0], x.shape[1], img_rows, img_cols)) + fill y = numpy.zeros((x.shape[0], x.shape[1], img_rows, img_cols), dtype=x.dtype) + fill
y[:, :, pad_h:(img_rows-pad_h), pad_w:(img_cols-pad_w)] = x y[:, :, pad_h:(img_rows-pad_h), pad_w:(img_cols-pad_w)] = x
gx = numpy.zeros_like(y) gx = numpy.zeros_like(y)
for n in xrange(x.shape[0]): for n in xrange(x.shape[0]):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论