Simplified version of :class:`Conv2dLayer`. Parameters ---------- n_filter : int The number of filters. filter_size : tuple of int The filter size (height, width). strides : tuple of int The sliding window strides of corresponding input dimensions.
| 146 | |
| 147 | |
| 148 | class Conv2d(Layer): |
| 149 | """Simplified version of :class:`Conv2dLayer`. |
| 150 | |
| 151 | Parameters |
| 152 | ---------- |
| 153 | n_filter : int |
| 154 | The number of filters. |
| 155 | filter_size : tuple of int |
| 156 | The filter size (height, width). |
| 157 | strides : tuple of int |
| 158 | The sliding window strides of corresponding input dimensions. |
| 159 | It must be in the same order as the ``shape`` parameter. |
| 160 | dilation_rate : tuple of int |
| 161 | Specifying the dilation rate to use for dilated convolution. |
| 162 | act : activation function |
| 163 | The activation function of this layer. |
| 164 | padding : str |
| 165 | The padding algorithm type: "SAME" or "VALID". |
| 166 | data_format : str |
| 167 | "channels_last" (NHWC, default) or "channels_first" (NCHW). |
| 168 | W_init : initializer |
| 169 | The initializer for the the weight matrix. |
| 170 | b_init : initializer or None |
| 171 | The initializer for the the bias vector. If None, skip biases. |
| 172 | in_channels : int |
| 173 | The number of in channels. |
| 174 | name : None or str |
| 175 | A unique layer name. |
| 176 | |
| 177 | Examples |
| 178 | -------- |
| 179 | With TensorLayer |
| 180 | |
| 181 | >>> net = tl.layers.Input([8, 400, 400, 3], name='input') |
| 182 | >>> conv2d = tl.layers.Conv2d(n_filter=32, filter_size=(3, 3), strides=(2, 2), b_init=None, in_channels=3, name='conv2d_1') |
| 183 | >>> print(conv2d) |
| 184 | >>> tensor = tl.layers.Conv2d(n_filter=32, filter_size=(3, 3), strides=(2, 2), act=tf.nn.relu, name='conv2d_2')(net) |
| 185 | >>> print(tensor) |
| 186 | |
| 187 | """ |
| 188 | |
| 189 | def __init__( |
| 190 | self, |
| 191 | n_filter=32, |
| 192 | filter_size=(3, 3), |
| 193 | strides=(1, 1), |
| 194 | act=None, |
| 195 | padding='SAME', |
| 196 | data_format='channels_last', |
| 197 | dilation_rate=(1, 1), |
| 198 | W_init=tl.initializers.truncated_normal(stddev=0.02), |
| 199 | b_init=tl.initializers.constant(value=0.0), |
| 200 | in_channels=None, |
| 201 | name=None # 'conv2d', |
| 202 | ): |
| 203 | super().__init__(name, act=act) |
| 204 | self.n_filter = n_filter |
| 205 | self.filter_size = filter_size |
no outgoing calls
searching dependent graphs…