fix above comments

revert-3824-remove_grad_op_type
chengduoZH 8 years ago
parent f715c740bf
commit 2710584ff1

File diff suppressed because it is too large Load Diff

@ -6161,12 +6161,6 @@ def img_conv3d_layer(input,
param_attr=None, param_attr=None,
shared_biases=True, shared_biases=True,
layer_attr=None, layer_attr=None,
filter_size_y=None,
stride_y=None,
padding_y=None,
filter_size_z=None,
stride_z=None,
padding_z=None,
trans=False, trans=False,
layer_type=None): layer_type=None):
""" """
@ -6175,7 +6169,7 @@ def img_conv3d_layer(input,
.. code-block:: python .. code-block:: python
conv = img_conv3d_layer(input=data, filter_size=1, filter_size_y=1, conv = img_conv3d_layer(input=data, filter_size=1,
num_channels=8, num_channels=8,
num_filters=16, stride=1, num_filters=16, stride=1,
bias_attr=False, bias_attr=False,
@ -6185,13 +6179,8 @@ def img_conv3d_layer(input,
:type name: basestring :type name: basestring
:param input: Layer Input. :param input: Layer Input.
:type input: LayerOutput :type input: LayerOutput
:param filter_size: The x dimension of a filter kernel. Or input a tuple for :param filter_size: The x dimension of a filter kernel. Or input a list.
two image dimension.
:type filter_size: int|tuple|list :type filter_size: int|tuple|list
:param filter_size_y: The y dimension of a filter kernel. Since PaddlePaddle
currently supports rectangular filters, the filter's
shape will be (filter_size, filter_size_y).
:type filter_size_y: int|None
:param num_filters: Each filter group's number of filter :param num_filters: Each filter group's number of filter
:param act: Activation type. Default is tanh :param act: Activation type. Default is tanh
:type act: BaseActivation :type act: BaseActivation
@ -6200,13 +6189,9 @@ def img_conv3d_layer(input,
:param stride: The x dimension of the stride. Or input a tuple for two image :param stride: The x dimension of the stride. Or input a tuple for two image
dimension. dimension.
:type stride: int|tuple|list :type stride: int|tuple|list
:param stride_y: The y dimension of the stride.
:type stride_y: int
:param padding: The x dimension of the padding. Or input a tuple for two :param padding: The x dimension of the padding. Or input a tuple for two
image dimension image dimension
:type padding: int|tuple|list :type padding: int|tuple|list
:param padding_y: The y dimension of the padding.
:type padding_y: int
:param bias_attr: Convolution bias attribute. None means default bias. :param bias_attr: Convolution bias attribute. None means default bias.
False means no bias. False means no bias.
:type bias_attr: ParameterAttribute|False :type bias_attr: ParameterAttribute|False
@ -6233,47 +6218,26 @@ def img_conv3d_layer(input,
assert input.num_filters is not None assert input.num_filters is not None
num_channels = input.num_filters num_channels = input.num_filters
if filter_size_y is None: if isinstance(filter_size, collections.Sequence):
if isinstance(filter_size, collections.Sequence): assert len(filter_size) == 3
assert len(filter_size) == 2 filter_size, filter_size_y, filter_size_z = filter_size
filter_size, filter_size_y = filter_size else:
else: filter_size_y = filter_size
filter_size_y = filter_size filter_size_z = filter_size
if filter_size_z is None:
if isinstance(filter_size, collections.Sequence):
assert len(filter_size) == 2
filter_size, filter_size_z = filter_size
else:
filter_size_z = filter_size
if stride_y is None:
if isinstance(stride, collections.Sequence):
assert len(stride) == 2
stride, stride_y = stride
else:
stride_y = stride
if stride_z is None:
if isinstance(stride, collections.Sequence):
assert len(stride) == 2
stride, stride_z = stride
else:
stride_z = stride
if padding_y is None: if isinstance(stride, collections.Sequence):
if isinstance(padding, collections.Sequence): assert len(stride) == 3
assert len(padding) == 2 stride, stride_y, stride_z = stride
padding, padding_y = padding else:
else: stride_y = stride
padding_y = padding stride_z = stride
if padding_z is None: if isinstance(padding, collections.Sequence):
if isinstance(padding, collections.Sequence): assert len(padding) == 3
assert len(padding) == 2 padding, padding_y, padding_z = padding
padding, padding_z = padding else:
else: padding_y = padding
padding_z = padding padding_z = padding
if param_attr.attr.get('initial_smart'): if param_attr.attr.get('initial_smart'):
# special initial for conv layers. # special initial for conv layers.

@ -14,23 +14,44 @@ padding_y = 1
padding_z = 1 padding_z = 1
groups = 1 groups = 1
data = data_layer( data1 = data_layer(name='data1', size=2016 * num_channels, height=48, width=42)
name='data1', size=12096 * num_channels, height=48, width=42, depth=6)
conv3d = img_conv3d_layer( img_conv_layer(
input=data1,
filter_size=filter_size,
num_channels=num_channels,
num_filters=16,
stride=stride,
padding=padding,
act=LinearActivation(),
bias_attr=False)
data = data_layer(
name='data', size=12096 * num_channels, height=48, width=42, depth=6)
# first
conv3d_1 = img_conv3d_layer(
input=data, input=data,
name='conv3d_1', name='conv3d_1',
num_filters=16, num_filters=16,
num_channels=num_channels, num_channels=num_channels,
filter_size=filter_size, filter_size=filter_size,
filter_size_y=filter_size,
filter_size_z=filter_size,
stride=stride, stride=stride,
stride_y=stride_y,
stride_z=stride_z,
padding=padding, padding=padding,
padding_y=padding_y, groups=groups,
padding_z=padding_z, bias_attr=True,
shared_biases=True,
trans=False,
layer_type="conv3d",
act=LinearActivation())
# second
conv3d_2 = img_conv3d_layer(
input=data,
name='conv3d_2',
num_filters=16,
num_channels=num_channels,
filter_size=[filter_size, filter_size_y, filter_size_z],
stride=[stride, stride_y, stride_z],
padding=[padding, padding_y, padding_z],
groups=groups, groups=groups,
bias_attr=True, bias_attr=True,
shared_biases=True, shared_biases=True,
@ -38,61 +59,33 @@ conv3d = img_conv3d_layer(
layer_type="conv3d", layer_type="conv3d",
act=LinearActivation()) act=LinearActivation())
deconv3d = img_conv3d_layer( # first
deconv3d_1 = img_conv3d_layer(
input=data, input=data,
name='deconv3d_1', name='deconv3d_1',
num_filters=16, num_filters=16,
num_channels=num_channels, num_channels=num_channels,
filter_size=filter_size, filter_size=filter_size,
filter_size_y=filter_size,
filter_size_z=filter_size,
stride=stride, stride=stride,
stride_y=stride_y,
stride_z=stride_z,
padding=padding, padding=padding,
padding_y=padding_y,
padding_z=padding_z,
groups=groups, groups=groups,
bias_attr=True, bias_attr=True,
shared_biases=True, shared_biases=True,
trans=True, trans=False,
layer_type="deconv3d", layer_type="deconv3d",
act=LinearActivation()) act=LinearActivation())
# second
data = data_layer(name="input", size=8 * 16 * 16) deconv3d_2 = img_conv3d_layer(
conv1 = img_conv_layer(
input=data,
filter_size=1,
filter_size_y=1,
num_channels=8,
num_filters=16,
stride=1,
bias_attr=False,
act=ReluActivation(),
layer_type="exconv")
conv2 = img_conv_layer(
input=data,
filter_size=1,
filter_size_y=1,
num_channels=8,
num_filters=16,
stride=1,
bias_attr=False,
act=ReluActivation(),
layer_type="exconv")
concat = concat_layer(input=[conv1, conv2])
conv = img_conv_layer(
input=data, input=data,
filter_size=1, name='deconv3d_2',
filter_size_y=1,
num_channels=8,
num_filters=16, num_filters=16,
stride=1, num_channels=num_channels,
filter_size=[filter_size, filter_size_y, filter_size_z],
stride=[stride, stride_y, stride_z],
padding=[padding, padding_y, padding_z],
groups=groups,
bias_attr=True, bias_attr=True,
act=LinearActivation(), shared_biases=True,
groups=2, trans=False,
layer_type="exconv") layer_type="deconv3d",
act=LinearActivation())
outputs(concat, conv)

Loading…
Cancel
Save