conv2d

tfsnippet.layers.conv2d(*args, **kwargs)

2D convolutional layer.

Parameters:
  • input (Tensor) – The input tensor, at least 4-d.
  • out_channels (int) – The channel numbers of the output.
  • kernel_size (int or (int, int)) – Kernel size over spatial dimensions.
  • strides (int or (int, int)) – Strides over spatial dimensions.
  • dilations (int) – The dilation factor over spatial dimensions.
  • padding – One of {“valid”, “same”}, case in-sensitive.
  • channels_last (bool) – Whether or not the channel axis is the last axis in input? (i.e., the data format is “NHWC”)
  • activation_fn – The activation function.
  • normalizer_fn – The normalizer function.
  • weight_norm (bool or (tf.Tensor) -> tf.Tensor)) –

    If True, apply weight_norm() on kernel. use_scale will be True if normalizer_fn is not specified, and False otherwise. The axis reduction will be determined by the layer.

    If it is a callable function, then it will be used to normalize the kernel instead of weight_norm(). The user must ensure the axis reduction is correct by themselves.

  • gated (bool) – Whether or not to use gate on output? output = activation_fn(output) * sigmoid(gate).
  • gate_sigmoid_bias (Tensor) – The bias added to gate before applying the sigmoid activation.
  • kernel (Tensor) – Instead of creating a new variable, use this tensor.
  • kernel_mask (Tensor) – If specified, multiply this mask onto kernel, i.e., the actual kernel to use will be kernel * kernel_mask.
  • kernel_initializer – The initializer for kernel. Would be default_kernel_initializer(...) if not specified.
  • kernel_regularizer – The regularizer for kernel.
  • kernel_constraint – The constraint for kernel.
  • use_bias (bool or None) – Whether or not to use bias? If True, will always use bias. If None, will use bias only if normalizer_fn is not given. If False, will never use bias. Default is None.
  • bias (Tensor) – Instead of creating a new variable, use this tensor.
  • bias_initializer – The initializer for bias.
  • bias_regularizer – The regularizer for bias.
  • bias_constraint – The constraint for bias.
  • trainable (bool) – Whether or not the parameters are trainable?
  • name (str) – Default name of the variable scope. Will be uniquified. If not specified, generate one according to the class name.
  • scope (str) – The name of the variable scope.
Returns:

The output tensor.

Return type:

tf.Tensor