提交 d68ac777 authored 作者: Gabe Schwartz's avatar Gabe Schwartz

Documentation, added __setstate__, small fixes.

上级 9f37bce1
...@@ -131,7 +131,7 @@ def _dnn_check_version(): ...@@ -131,7 +131,7 @@ def _dnn_check_version():
if v < 5000: if v < 5000:
return False, "cuDNN version is too old. Update to v5, was %d." % v return False, "cuDNN version is too old. Update to v5, was %d." % v
# 5200 should not print warning with cudnn 5.1 final. # 5200 should not print warning with cudnn 5.1 final.
if v > 6020: if v >= 6100:
warnings.warn("Your cuDNN version is more recent than " warnings.warn("Your cuDNN version is more recent than "
"Theano. If you encounter problems, try " "Theano. If you encounter problems, try "
"updating Theano or downgrading cuDNN to " "updating Theano or downgrading cuDNN to "
...@@ -401,7 +401,6 @@ class GpuDnnConvDesc(COp): ...@@ -401,7 +401,6 @@ class GpuDnnConvDesc(COp):
assert conv_mode in ('conv', 'cross') assert conv_mode in ('conv', 'cross')
self.conv_mode = conv_mode self.conv_mode = conv_mode
assert len(dilation) in (2, 3)
assert len(dilation) == len(subsample) assert len(dilation) == len(subsample)
self.dilation = dilation self.dilation = dilation
...@@ -487,6 +486,11 @@ class GpuDnnConvDesc(COp): ...@@ -487,6 +486,11 @@ class GpuDnnConvDesc(COp):
def c_code_cache_version(self): def c_code_cache_version(self):
return (super(GpuDnnConvDesc, self).c_code_cache_version(), version()) return (super(GpuDnnConvDesc, self).c_code_cache_version(), version())
def __setstate__(self, d):
self.__dict__.update(d)
if not hasattr(self, "dilation"):
self.dilation = (1,) * len(self.subsample)
# scalar constants # scalar constants
_zero = constant(np.asarray(0.0, dtype='float64')) _zero = constant(np.asarray(0.0, dtype='float64'))
...@@ -935,16 +939,20 @@ def dnn_conv(img, kerns, border_mode='valid', subsample=(1, 1), dilation=(1, 1), ...@@ -935,16 +939,20 @@ def dnn_conv(img, kerns, border_mode='valid', subsample=(1, 1), dilation=(1, 1),
could be directly specified by an integer or a pair of integers. could be directly specified by an integer or a pair of integers.
subsample subsample
Perform subsampling of the output (default: (1, 1)). Perform subsampling of the output (default: (1, 1)).
dilation
Filter dilation factor. A dilation factor of d is equivalent to a
convolution with d - 1 zeros inserted between neighboring filter
values.
conv_mode conv_mode
Perform convolution (kernels flipped) or cross-correlation. Perform convolution (kernels flipped) or cross-correlation.
One of 'conv', 'cross' (default: 'conv'). One of 'conv', 'cross' (default: 'conv').
direction_hint direction_hint
Used by graph optimizers to change algorithm choice. Used by graph optimizers to change algorithm choice.
By default, GpuDnnConv will be used to carry out the convolution. By default, GpuDnnConv will be used to carry out the convolution.
If border_mode is 'valid', subsample is (1, 1) and direction_hint is If border_mode is 'valid', subsample is (1, 1), dilation is (1, 1), and
'bprop weights', it will use GpuDnnConvGradW. direction_hint is 'bprop weights', it will use GpuDnnConvGradW.
If border_mode is 'full', subsample is (1, 1) and direction_hint is If border_mode is 'full', subsample is (1, 1), dilation is (1, 1), and
*not* 'forward!', it will use GpuDnnConvGradI. direction_hint is *not* 'forward!', it will use GpuDnnConvGradI.
This parameter is used internally by graph optimizers and may be This parameter is used internally by graph optimizers and may be
removed at any time without a deprecation period. You have been warned. removed at any time without a deprecation period. You have been warned.
algo : {'none', 'small', 'large', 'fft', 'guess_once', 'guess_on_shape_change', 'time_once', 'time_on_shape_change'} algo : {'none', 'small', 'large', 'fft', 'guess_once', 'guess_on_shape_change', 'time_once', 'time_on_shape_change'}
...@@ -1053,17 +1061,23 @@ def dnn_conv3d(img, kerns, border_mode='valid', subsample=(1, 1, 1), dilation=(1 ...@@ -1053,17 +1061,23 @@ def dnn_conv3d(img, kerns, border_mode='valid', subsample=(1, 1, 1), dilation=(1
One of 'valid', 'full', 'half'; additionally, the padding size One of 'valid', 'full', 'half'; additionally, the padding size
could be directly specified by an integer or a pair of integers. could be directly specified by an integer or a pair of integers.
subsample subsample
Perform subsampling of the output (default: (1, 1)). Perform subsampling of the output (default: (1, 1, 1)).
dilation
Filter dilation factor. A dilation factor of d is equivalent to a
convolution with d - 1 zeros inserted between neighboring filter
values.
conv_mode conv_mode
Perform convolution (kernels flipped) or cross-correlation. Perform convolution (kernels flipped) or cross-correlation.
One of 'conv', 'cross' (default: 'conv'). One of 'conv', 'cross' (default: 'conv').
direction_hint direction_hint
Used by graph optimizers to change algorithm choice. Used by graph optimizers to change algorithm choice.
By default, GpuDnnConv will be used to carry out the convolution. By default, GpuDnnConv will be used to carry out the convolution.
If border_mode is 'valid', subsample is (1, 1) and direction_hint is If border_mode is 'valid', subsample is (1, 1, 1), dilation is
'bprop weights', it will use GpuDnnConvGradW. (1, 1, 1), and direction_hint is 'bprop weights', it will use
If border_mode is 'full', subsample is (1, 1) and direction_hint is GpuDnnConvGradW.
*not* 'forward!', it will use GpuDnnConvGradI. If border_mode is 'full', subsample is (1, 1, 1), dilation is
(1, 1, 1), and direction_hint is *not* 'forward!', it will use
GpuDnnConvGradI.
This parameter is used internally by graph optimizers and may be This parameter is used internally by graph optimizers and may be
removed at any time without a deprecation period. You have been warned. removed at any time without a deprecation period. You have been warned.
algo : convolution implementation to use. Only 'none' is implemented algo : convolution implementation to use. Only 'none' is implemented
...@@ -1168,12 +1182,12 @@ def dnn_gradweight(img, topgrad, kerns_shp, border_mode='valid', ...@@ -1168,12 +1182,12 @@ def dnn_gradweight(img, topgrad, kerns_shp, border_mode='valid',
def dnn_gradweight3d(img, topgrad, kerns_shp, border_mode='valid', def dnn_gradweight3d(img, topgrad, kerns_shp, border_mode='valid',
subsample=(1, 1, 1), conv_mode='conv', precision=None): subsample=(1, 1, 1), dilation=(1, 1, 1), conv_mode='conv', precision=None):
""" """
3d version of dnn_gradweight 3d version of dnn_gradweight
""" """
return dnn_gradweight(img, topgrad, kerns_shp, border_mode, return dnn_gradweight(img, topgrad, kerns_shp, border_mode,
subsample, conv_mode, precision) subsample, dilation, conv_mode, precision)
def dnn_gradinput(kerns, topgrad, img_shp, border_mode='valid', def dnn_gradinput(kerns, topgrad, img_shp, border_mode='valid',
...@@ -1196,12 +1210,12 @@ def dnn_gradinput(kerns, topgrad, img_shp, border_mode='valid', ...@@ -1196,12 +1210,12 @@ def dnn_gradinput(kerns, topgrad, img_shp, border_mode='valid',
def dnn_gradinput3d(kerns, topgrad, img_shp, border_mode='valid', def dnn_gradinput3d(kerns, topgrad, img_shp, border_mode='valid',
subsample=(1, 1, 1), conv_mode='conv', precision=None): subsample=(1, 1, 1), dilation=(1, 1, 1), conv_mode='conv', precision=None):
""" """
3d version of `dnn_gradinput`. 3d version of `dnn_gradinput`.
""" """
return dnn_gradinput(kerns, topgrad, img_shp, border_mode, subsample, return dnn_gradinput(kerns, topgrad, img_shp, border_mode, subsample,
conv_mode, precision) dilation, conv_mode, precision)
class GpuDnnPoolDesc(Op): class GpuDnnPoolDesc(Op):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论