Convolutional Layers

[source]

Conv2d

polyaxon.layers.convolutional.Conv2d(mode, num_filter, filter_size, strides=1, padding='SAME', activation='linear', bias=True, weights_init='uniform_scaling', bias_init='zeros', regularizer=None, scale=0.001, trainable=True, restore=True, name='Conv2D')

Adds a 2D convolution layer.

This operation creates a variable called 'w', representing the convolutional kernel, that is convolved with the input. A second variable called 'b' is added to the result of the convolution operation.

  • Args:

    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • num_filter: int. The number of convolutional filters.
    • filter_size: int or list of int. Size of filters.
    • strides: 'intor list ofint`. Strides of conv operation.
      • Default: [1 1 1 1].
    • padding: str from "SAME", "VALID". Padding algo to use.
      • Default: 'SAME'.
    • activation: str (name) or function (returning a Tensor) or None.
      • Default: 'linear'.
    • bias: bool. If True, a bias is used.
    • weights_init: str (name) or Tensor. Weights initialization.
      • Default: 'truncated_normal'.
    • bias_init: str (name) or Tensor. Bias initialization.
      • Default: 'zeros'.
    • regularizer: str (name) or Tensor. Add a regularizer to this layer weights.
      • Default: None.
    • scale: float. Regularizer decay parameter. Default: 0.001.
    • trainable: bool. If True, weights will be trainable.
    • restore: bool. If True, this layer weights will be restored when loading a model.
    • name: A name for this layer (optional). Default: 'Conv2D'.
  • Attributes:

    • w: Variable. Variable representing filter weights.
    • b: Variable. Variable representing biases.

[source]

Conv2dTranspose

polyaxon.layers.convolutional.Conv2dTranspose(mode, num_filter, filter_size, output_shape, strides=1, padding='SAME', activation='linear', bias=True, weights_init='uniform_scaling', bias_init='zeros', regularizer=None, scale=0.001, trainable=True, restore=True, name='Conv2DTranspose')

Adds a Convolution 2D Transpose.

This operation is sometimes called "deconvolution" after (Deconvolutional - Networks)[http://www.matthewzeiler.com/pubs/cvpr2010/cvpr2010.pdf], but is actually the transpose (gradient) of conv2d rather than an actual deconvolution.

  • Args:

    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • num_filter: int. The number of convolutional filters.
    • filter_size: int or list of int. Size of filters.
    • output_shape: list of int. Dimensions of the output tensor. Can optionally include the number of conv filters. [new height, new width, num_filter] or [new height, new width].
    • strides: int or list of int. Strides of conv operation.
      • Default: [1 1 1 1].
    • padding: str from "SAME", "VALID". Padding algo to use.
      • Default: 'SAME'.
    • activation: str (name) or function (returning a Tensor).
      • Default: 'linear'.
    • bias: bool. If True, a bias is used.
    • weights_init: str (name) or Tensor. Weights initialization.
      • Default: 'truncated_normal'.
    • bias_init: str (name) or Tensor. Bias initialization.
      • Default: 'zeros'.
    • regularizer: str (name) or Tensor. Add a regularizer to this layer weights.
      • Default: None.
    • scale: float. Regularizer decay parameter. Default: 0.001.
    • trainable: bool. If True, weights will be trainable.
    • restore: bool. If True, this layer weights will be restored when loading a model.
    • name: A name for this layer (optional). Default: 'Conv2DTranspose'.
  • Attributes:

    • w: Variable. Variable representing filter weights.
    • b: Variable. Variable representing biases.

[source]

MaxPool2d

polyaxon.layers.convolutional.MaxPool2d(mode, kernel_size, strides=None, padding='SAME', name='MaxPool2D')

Adds Max Pooling 2D.

  • Args:
    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • kernel_size: 'intorlist of int`. Pooling kernel size.
    • strides: 'intorlist of int`. Strides of conv operation.
      • Default: SAME as kernel_size.
    • padding: str from "SAME", "VALID". Padding algo to use.
      • Default: 'SAME'.
    • name: A name for this layer (optional). Default: 'MaxPool2D'.

[source]

AvgPool2d

polyaxon.layers.convolutional.AvgPool2d(mode, kernel_size, strides=None, padding='SAME', name='AvgPool2D')

Adds Average Pooling 2D.

  • Args:
    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • kernel_size: 'intorlist of int`. Pooling kernel size.
    • strides: 'intorlist of int`. Strides of conv operation.
      • Default: SAME as kernel_size.
    • padding: str from "SAME", "VALID". Padding algo to use.
      • Default: 'SAME'.
    • name: A name for this layer (optional). Default: 'AvgPool2D'.

[source]

Upsample2d

polyaxon.layers.convolutional.Upsample2d(mode, kernel_size, name='UpSample2D')

Adds UpSample 2D operation.

  • Args:
    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • kernel_size: 'intorlist of int`. Upsampling kernel size.
    • name: A name for this layer (optional). Default: 'UpSample2D'.

[source]

HighwayConv2d

polyaxon.layers.convolutional.HighwayConv2d(mode, num_filter, filter_size, strides=1, padding='SAME', activation='linear', weights_init='uniform_scaling', bias_init='zeros', regularizer=None, scale=0.001, trainable=True, restore=True, name='HighwayConv2D')

Adds a Highway Convolution 2D.

  • Args:

    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • num_filter: int. The number of convolutional filters.
    • filter_size: 'intorlist of int`. Size of filters.
    • strides: 'intorlist of int`. Strides of conv operation.
      • Default: [1 1 1 1].
    • padding: str from "SAME", "VALID". Padding algo to use.
      • Default: 'SAME'.
    • activation: str (name) or function (returning a Tensor).
      • Default: 'linear'.
    • weights_init: str (name) or Tensor. Weights initialization.
      • Default: 'truncated_normal'.
    • bias_init: str (name) or Tensor. Bias initialization.
      • Default: 'zeros'.
    • regularizer: str (name) or Tensor. Add a regularizer to this layer weights.
      • Default: None.
    • scale: float. Regularizer decay parameter. Default: 0.001.
    • trainable: bool. If True, weights will be trainable.
    • restore: bool. If True, this layer weights will be restored when loading a model.
    • name: A name for this layer (optional). Default: 'Conv2D'.
  • Attributes:

    • w: Variable. Variable representing filter weights.
    • w_t: Variable. Variable representing gate weights.
    • b: Variable. Variable representing biases.
    • b_t: Variable. Variable representing gate biases.

[source]

Upscore

polyaxon.layers.convolutional.Upscore(mode, num_classes, shape=None, kernel_size=4, strides=2, trainable=True, restore=True, name='Upscore')

Adds an Upscore layer.

This implements the upscore layer as used in (Fully Convolutional Networks)[http://arxiv.org/abs/1411.4038]. The upscore layer is initialized as bilinear upsampling filter.

  • Args:

    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • num_classes: int. Number of output feature maps.
    • shape: list of int. Dimension of the output map [batch_size, new height, new width]. For convinience four values are allows [batch_size, new height, new width, X], where X is ignored.
    • kernel_size: 'intorlist of int`. Upsampling kernel size.
    • strides: 'intorlist of int`. Strides of conv operation.
      • Default: [1 2 2 1].
    • trainable: bool. If True, weights will be trainable.
    • restore: bool. If True, this layer weights will be restored when loading a model.
    • name: A name for this layer (optional). Default: 'Upscore'.
  • Links: (Fully Convolutional Networks)[http://arxiv.org/abs/1411.4038]


[source]

Conv1d

polyaxon.layers.convolutional.Conv1d(mode, num_filter, filter_size, strides=1, padding='SAME', activation='linear', bias=True, weights_init='uniform_scaling', bias_init='zeros', regularizer=None, scale=0.001, trainable=True, restore=True, name='Conv1D')

Adds a Convolution 1D.

  • Args:

    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • num_filter: int. The number of convolutional filters.
    • filter_size: 'intorlist of int`. Size of filters.
    • strides: 'intorlist of int`. Strides of conv operation.
      • Default: [1 1 1 1].
    • padding: str from "SAME", "VALID". Padding algo to use.
      • Default: 'SAME'.
    • activation: str (name) or function (returning a Tensor).
      • Default: 'linear'.
    • bias: bool. If True, a bias is used.
    • weights_init: str (name) or Tensor. Weights initialization.
      • Default: 'truncated_normal'.
    • bias_init: str (name) or Tensor. Bias initialization.
      • Default: 'zeros'.
    • regularizer: str (name) or Tensor. Add a regularizer to this layer weights.
      • Default: None.
    • scale: float. Regularizer decay parameter. Default: 0.001.
    • trainable: bool. If True, weights will be trainable.
    • restore: bool. If True, this layer weights will be restored when loading a model.
    • name: A name for this layer (optional). Default: 'Conv1D'.
  • Attributes:

    • w: Variable. Variable representing filter weights.
    • b: Variable. Variable representing biases.

[source]

MaxPool1d

polyaxon.layers.convolutional.MaxPool1d(mode, kernel_size, strides=None, padding='SAME', name='MaxPool1D')

Adds Max Pooling 1D.

  • Args:
    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • kernel_size: int or list of int. Pooling kernel size.
    • strides: int or list of int. Strides of conv operation.
      • Default: SAME as kernel_size.
    • padding: str from "SAME", "VALID". Padding algo to use.
      • Default: 'SAME'.
    • name: A name for this layer (optional). Default: 'MaxPool1D'.

[source]

AvgPool1d

polyaxon.layers.convolutional.AvgPool1d(mode, kernel_size, strides=None, padding='SAME', name='AvgPool1D')

Average Pooling 1D.

  • Args:
    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • kernel_size: int or list of int. Pooling kernel size.
    • strides: int or list of int. Strides of conv operation.
      • Default: SAME as kernel_size.
    • padding: str from "SAME", "VALID". Padding algo to use.
      • Default: 'SAME'.
    • name: A name for this layer (optional). Default: 'AvgPool1D'.

[source]

HighwayConv1d

polyaxon.layers.convolutional.HighwayConv1d(mode, num_filter, filter_size, strides=1, padding='SAME', activation='linear', weights_init='uniform_scaling', bias_init='zeros', regularizer=None, scale=0.001, trainable=True, restore=True, name='HighwayConv1D')

Adds a Highway Convolution 1D.

  • Args:

    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • num_filter: int. The number of convolutional filters.
    • filter_size: 'intorlist of int`. Size of filters.
    • strides: 'intorlist of int`. Strides of conv operation.
      • Default: [1 1 1 1].
    • padding: str from "SAME", "VALID". Padding algo to use.
      • Default: 'SAME'.
    • activation: str (name) or function (returning a Tensor).
      • Default: 'linear'.
    • weights_init: str (name) or Tensor. Weights initialization.
      • Default: 'truncated_normal'.
    • bias_init: str (name) or Tensor. Bias initialization.
      • Default: 'zeros'.
    • regularizer: str (name) or Tensor. Add a regularizer to this layer weights.
      • Default: None.
    • scale: float. Regularizer decay parameter. Default: 0.001.
    • trainable: bool. If True, weights will be trainable.
    • restore: bool. If True, this layer weights will be restored when loading a model.
    • name: A name for this layer (optional). Default: 'HighwayConv1D'.
  • Attributes:

    • w: Variable. Variable representing filter weights.
    • w_t: Variable. Variable representing gate weights.
    • b: Variable. Variable representing biases.
    • b_t: Variable. Variable representing gate biases.

[source]

Conv3d

polyaxon.layers.convolutional.Conv3d(mode, num_filter, filter_size, strides=1, padding='SAME', activation='linear', bias=True, weights_init='uniform_scaling', bias_init='zeros', regularizer=None, scale=0.001, trainable=True, restore=True, name='Conv3D')

Adds Convolution 3D.

  • Args:

    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • num_filter: int. The number of convolutional filters.
    • filter_size: int or list of int. Size of filters.
    • strides: 'intor list ofint`. Strides of conv operation.
      • Default: [1 1 1 1 1]. Must have strides[0] = strides[4] = 1.
    • padding: str from "SAME", "VALID". Padding algo to use.
      • Default: 'SAME'.
    • activation: str (name) or function (returning a Tensor).
      • Default: 'linear'.
    • bias: bool. If True, a bias is used.
    • weights_init: str (name) or Tensor. Weights initialization.
      • Default: 'truncated_normal'.
    • bias_init: str (name) or Tensor. Bias initialization.
      • Default: 'zeros'.
    • regularizer: str (name) or Tensor. Add a regularizer to this layer weights.
      • Default: None.
    • scale: float. Regularizer decay parameter. Default: 0.001.
    • trainable: bool. If True, weights will be trainable.
    • restore: bool. If True, this layer weights will be restored when loading a model.
    • name: A name for this layer (optional). Default: 'Conv3D'.
  • Attributes:

    • w: Variable. Variable representing filter weights.
    • b: Variable. Variable representing biases.

[source]

Conv3dTranspose

polyaxon.layers.convolutional.Conv3dTranspose(mode, num_filter, filter_size, output_shape, strides=1, padding='SAME', activation='linear', bias=True, weights_init='uniform_scaling', bias_init='zeros', regularizer=None, scale=0.001, trainable=True, restore=True, name='Conv3DTranspose')

Adds Convolution 3D Transpose.

This operation is sometimes called "deconvolution" after (Deconvolutional - Networks)[http://www.matthewzeiler.com/pubs/cvpr2010/cvpr2010.pdf], but is actually the transpose (gradient) of conv3d rather than an actual deconvolution.

  • Args:

    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • num_filter: int. The number of convolutional filters.
    • filter_size: int or list of int. Size of filters.
    • output_shape: list of int. Dimensions of the output tensor. Can optionally include the number of conv filters. [new depth, new height, new width, num_filter] or [new depth, new height, new width].
    • strides: int or list of int. Strides of conv operation.
      • Default: [1 1 1 1 1].
    • padding: str from "SAME", "VALID". Padding algo to use.
      • Default: 'SAME'.
    • activation: str (name) or function (returning a Tensor).
      • Default: 'linear'.
    • bias: bool. If True, a bias is used.
    • weights_init: str (name) or Tensor. Weights initialization.
      • Default: 'truncated_normal'.
    • bias_init: str (name) or Tensor. Bias initialization.
      • Default: 'zeros'.
    • regularizer: str (name) or Tensor. Add a regularizer to this layer weights.
      • Default: None.
    • scale: float. Regularizer decay parameter. Default: 0.001.
    • trainable: bool. If True, weights will be trainable.
    • restore: bool. If True, this layer weights will be restored when loading a model.
    • name: A name for this layer (optional). Default: 'Conv2DTranspose'.
  • Attributes:

    • w: Variable. Variable representing filter weights.
    • b: Variable. Variable representing biases.

[source]

MaxPool3d

polyaxon.layers.convolutional.MaxPool3d(mode, kernel_size, strides=1, padding='SAME', name='MaxPool3D')

Max Pooling 3D.

  • Args:
    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • kernel_size: 'intorlist of int`. Pooling kernel size. Must have kernel_size[0] = kernel_size[1] = 1
    • strides: 'intorlist of int`. Strides of conv operation. Must have strides[0] = strides[4] = 1.
      • Default: [1 1 1 1 1]
    • padding: str from "SAME", "VALID". Padding algo to use.
      • Default: 'SAME'.
    • name: A name for this layer (optional). Default: 'MaxPool3D'.

[source]

AvgPool3d

polyaxon.layers.convolutional.AvgPool3d(mode, kernel_size, strides=None, padding='SAME', name='AvgPool3D')

Average Pooling 3D.

  • Args:
    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • kernel_size: 'intorlist of int`. Pooling kernel size. Must have kernel_size[0] = kernel_size[1] = 1
    • strides: 'intorlist of int`. Strides of conv operation. Must have strides[0] = strides[4] = 1.
      • Default: [1 1 1 1 1]
    • padding: str from "SAME", "VALID". Padding algo to use.
      • Default: 'SAME'.
    • name: A name for this layer (optional). Default: 'AvgPool3D'.

[source]

GlobalMaxPool

polyaxon.layers.convolutional.GlobalMaxPool(mode, name='GlobalMaxPool')

Adds a Global Max Pooling.

  • Args:
    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • name: A name for this layer (optional). Default: 'GlobalMaxPool'.

[source]

GlobalAvgPool

polyaxon.layers.convolutional.GlobalAvgPool(mode, name='GlobalAvgPool')

Adds a Global Average Pooling.

  • Args:
    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • name: A name for this layer (optional). Default: 'GlobalAvgPool'.

[source]

ResidualBlock

polyaxon.layers.convolutional.ResidualBlock(mode, num_blocks, out_channels, downsample=False, downsample_strides=2, activation='relu', batch_norm=True, bias=True, weights_init='variance_scaling', bias_init='zeros', regularizer='l2_regularizer', scale=0.0001, trainable=True, restore=True, name='ResidualBlock')

Adds a Residual Block.

A residual block as described in MSRA's Deep Residual Network paper. Full pre-activation architecture is used here.

  • Args:

    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • num_blocks: int. Number of layer blocks.
    • out_channels: int. The number of convolutional filters of the convolution layers.
    • downsample: bool. If True, apply downsampling using 'downsample_strides' for strides.
    • downsample_strides: int. The strides to use when downsampling.
    • activation: str (name) or function (returning a Tensor).
      • Default: 'linear'.
    • batch_norm: bool. If True, apply batch normalization.
    • bias: bool. If True, a bias is used.
    • weights_init: str (name) or Tensor. Weights initialization.
      • Default: 'uniform_scaling'.
    • bias_init: str (name) or tf.Tensor. Bias initialization.
      • Default: 'zeros'.
    • regularizer: str (name) or Tensor. Add a regularizer to this layer weights.
      • Default: None.
    • scale: float. Regularizer decay parameter. Default: 0.001.
    • trainable: bool. If True, weights will be trainable.
    • restore: bool. If True, this layer weights will be restored when loading a model.
    • name: A name for this layer (optional). Default: 'ShallowBottleneck'.
  • References:

    • Deep Residual Learning for Image Recognition. Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun. 2015.
    • Identity Mappings in Deep Residual Networks. Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun. 2015.
  • Links:

    • [http://arxiv.org/pdf/1512.03385v1.pdf] (http://arxiv.org/pdf/1512.03385v1.pdf)
    • [Identity Mappings in Deep Residual Networks] (https://arxiv.org/pdf/1603.05027v2.pdf)

[source]

ResidualBottleneck

polyaxon.layers.convolutional.ResidualBottleneck(mode, num_blocks, bottleneck_size, out_channels, downsample=False, downsample_strides=2, activation='relu', batch_norm=True, bias=True, weights_init='variance_scaling', bias_init='zeros', regularizer='l2_regularizer', scale=0.0001, trainable=True, restore=True, name='ResidualBottleneck')

Adds a Residual Bottleneck.

A residual bottleneck block as described in MSRA's Deep Residual Network paper. Full pre-activation architecture is used here.

  • Args:

    • mode: str, Specifies if this training, evaluation or prediction. See Modes.
    • num_blocks: int. Number of layer blocks.
    • bottleneck_size: int. The number of convolutional filter of the bottleneck convolutional layer.
    • out_channels: int. The number of convolutional filters of the layers surrounding the bottleneck layer.
    • downsample: bool. If True, apply downsampling using 'downsample_strides' for strides.
    • downsample_strides: int. The strides to use when downsampling.
    • activation: str (name) or function (returning a Tensor).
      • Default: 'linear'.
    • batch_norm: bool. If True, apply batch normalization.
    • bias: bool. If True, a bias is used.
    • weights_init: str (name) or Tensor. Weights initialization.
      • Default: 'uniform_scaling'.
    • bias_init: str (name) or tf.Tensor. Bias initialization.
      • Default: 'zeros'.
    • regularizer: str (name) or Tensor. Add a regularizer to this layer weights.
      • Default: None.
    • scale: float. Regularizer decay parameter. Default: 0.001.
    • trainable: bool. If True, weights will be trainable.
    • restore: bool. If True, this layer weights will be restored when loading a model.
    • name: A name for this layer (optional). Default: 'DeepBottleneck'.
  • References:

    • Deep Residual Learning for Image Recognition. Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun. 2015.
    • Identity Mappings in Deep Residual Networks. Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun. 2015.
  • Links:

    • [http://arxiv.org/pdf/1512.03385v1.pdf] (http://arxiv.org/pdf/1512.03385v1.pdf)
    • [Identity Mappings in Deep Residual Networks] (https://arxiv.org/pdf/1603.05027v2.pdf)