Convolution 2D. Input: 4-D Tensor [batch, height, width, in_channels]. Output: 4-D Tensor [batch, new height, new width, nb_filter]. Arguments: incoming: `Tensor`. Incoming 4-D Tensor. nb_filter: `int`. The number of convolutional filters. filt
(incoming, nb_filter, filter_size, strides=1, padding='same',
activation='linear', bias=True, weights_init='uniform_scaling',
bias_init='zeros', regularizer=None, weight_decay=0.001,
trainable=True, restore=True, reuse=False, scope=None,
name="Conv2D")
| 15 | |
| 16 | |
| 17 | def conv_2d(incoming, nb_filter, filter_size, strides=1, padding='same', |
| 18 | activation='linear', bias=True, weights_init='uniform_scaling', |
| 19 | bias_init='zeros', regularizer=None, weight_decay=0.001, |
| 20 | trainable=True, restore=True, reuse=False, scope=None, |
| 21 | name="Conv2D"): |
| 22 | """ Convolution 2D. |
| 23 | |
| 24 | Input: |
| 25 | 4-D Tensor [batch, height, width, in_channels]. |
| 26 | |
| 27 | Output: |
| 28 | 4-D Tensor [batch, new height, new width, nb_filter]. |
| 29 | |
| 30 | Arguments: |
| 31 | incoming: `Tensor`. Incoming 4-D Tensor. |
| 32 | nb_filter: `int`. The number of convolutional filters. |
| 33 | filter_size: `int` or `list of int`. Size of filters. |
| 34 | strides: `int` or list of `int`. Strides of conv operation. |
| 35 | Default: [1 1 1 1]. |
| 36 | padding: `str` from `"same", "valid"`. Padding algo to use. |
| 37 | Default: 'same'. |
| 38 | activation: `str` (name) or `function` (returning a `Tensor`) or None. |
| 39 | Activation applied to this layer (see tflearn.activations). |
| 40 | Default: 'linear'. |
| 41 | bias: `bool`. If True, a bias is used. |
| 42 | weights_init: `str` (name) or `Tensor`. Weights initialization. |
| 43 | (see tflearn.initializations) Default: 'truncated_normal'. |
| 44 | bias_init: `str` (name) or `Tensor`. Bias initialization. |
| 45 | (see tflearn.initializations) Default: 'zeros'. |
| 46 | regularizer: `str` (name) or `Tensor`. Add a regularizer to this |
| 47 | layer weights (see tflearn.regularizers). Default: None. |
| 48 | weight_decay: `float`. Regularizer decay parameter. Default: 0.001. |
| 49 | trainable: `bool`. If True, weights will be trainable. |
| 50 | restore: `bool`. If True, this layer weights will be restored when |
| 51 | loading a model. |
| 52 | reuse: `bool`. If True and 'scope' is provided, this layer variables |
| 53 | will be reused (shared). |
| 54 | scope: `str`. Define this layer scope (optional). A scope can be |
| 55 | used to share variables between layers. Note that scope will |
| 56 | override name. |
| 57 | name: A name for this layer (optional). Default: 'Conv2D'. |
| 58 | |
| 59 | Attributes: |
| 60 | scope: `Scope`. This layer scope. |
| 61 | W: `Variable`. Variable representing filter weights. |
| 62 | b: `Variable`. Variable representing biases. |
| 63 | |
| 64 | """ |
| 65 | input_shape = utils.get_incoming_shape(incoming) |
| 66 | assert len(input_shape) == 4, "Incoming Tensor shape must be 4-D, not %d-D" % len(input_shape) |
| 67 | filter_size = utils.autoformat_filter_conv2d(filter_size, |
| 68 | input_shape[-1], |
| 69 | nb_filter) |
| 70 | strides = utils.autoformat_kernel_2d(strides) |
| 71 | padding = utils.autoformat_padding(padding) |
| 72 | |
| 73 | with tf.variable_scope(scope, default_name=name, values=[incoming], |
| 74 | reuse=reuse) as scope: |