@@ -35,11 +35,10 @@ class DeConv2d(Layer):
3535 The stride step (height, width).
3636 padding : str
3737 The padding algorithm type: "SAME" or "VALID".
38- batch_size : int or None
39- Require if TF < 1.3, int or None.
40- If None, try to find the `batch_size` from the first dim of net.outputs (you should define the `batch_size` in the input placeholder).
4138 act : activation function
4239 The activation function of this layer.
40+ data_format : str
41+ "channels_last" (NHWC, default) or "channels_first" (NCHW).
4342 W_init : initializer
4443 The initializer for the weight matrix.
4544 b_init : initializer or None
@@ -61,11 +60,12 @@ def __init__(
6160 prev_layer ,
6261 n_filter = 32 ,
6362 filter_size = (3 , 3 ),
64- out_size = (30 , 30 ), # remove
63+ # out_size=(30, 30), # remove
6564 strides = (2 , 2 ),
6665 padding = 'SAME' ,
67- batch_size = None , # remove
66+ # batch_size=None, # remove
6867 act = None ,
68+ data_format = 'channels_last' ,
6969 W_init = tf .truncated_normal_initializer (stddev = 0.02 ),
7070 b_init = tf .constant_initializer (value = 0.0 ),
7171 W_init_args = None , # TODO: Remove when TF <1.3 not supported
@@ -86,8 +86,8 @@ def __init__(
8686 raise ValueError ("len(strides) should be 2, DeConv2d and DeConv2dLayer are different." )
8787
8888 conv2d_transpose = tf .layers .Conv2DTranspose (
89- filters = n_filter , kernel_size = filter_size , strides = strides , padding = padding , activation = self . act ,
90- kernel_initializer = W_init , bias_initializer = b_init , name = name
89+ filters = n_filter , kernel_size = filter_size , strides = strides , padding = padding , data_format = data_format ,
90+ activation = self . act , kernel_initializer = W_init , bias_initializer = b_init , name = name
9191 )
9292
9393 self .outputs = conv2d_transpose (self .inputs )
@@ -116,6 +116,8 @@ class DeConv3d(Layer):
116116 The padding algorithm type: "SAME" or "VALID".
117117 act : activation function
118118 The activation function of this layer.
119+ data_format : str
120+ "channels_last" (NDHWC, default) or "channels_first" (NCDHW).
119121 W_init : initializer
120122 The initializer for the weight matrix.
121123 b_init : initializer or None
@@ -138,6 +140,7 @@ def __init__(
138140 strides = (2 , 2 , 2 ),
139141 padding = 'SAME' ,
140142 act = None ,
143+ data_format = 'channels_last' ,
141144 W_init = tf .truncated_normal_initializer (stddev = 0.02 ),
142145 b_init = tf .constant_initializer (value = 0.0 ),
143146 W_init_args = None , # TODO: Remove when TF <1.3 not supported
@@ -157,7 +160,7 @@ def __init__(
157160 # with tf.variable_scope(name) as vs:
158161 nn = tf .layers .Conv3DTranspose (
159162 filters = n_filter , kernel_size = filter_size , strides = strides , padding = padding , activation = self .act ,
160- kernel_initializer = W_init , bias_initializer = b_init , name = name
163+ data_format = data_format , kernel_initializer = W_init , bias_initializer = b_init , name = name
161164 )
162165
163166 self .outputs = nn (self .inputs )
0 commit comments