class_docstr: The :class:`DeformableConv2d` class is a 2D
  `Deformable Convolutional Networks <https://arxiv.org/abs/1703.06211>`__.
  
  Parameters
  ----------
  offset_layer : tf.Tensor
      To predict the offset of convolution operations.
      The shape is (batchsize, input height, input width, 2*(number of element in the convolution kernel))
      e.g. if apply a 3*3 kernel, the number of the last dimension should be 18 (2*3*3)
  n_filter : int
      The number of filters.
  filter_size : tuple of int
      The filter size (height, width).
  act : activation function
      The activation function of this layer.
  padding : str
      The padding algorithm type: "SAME" or "VALID".
  W_init : initializer
      The initializer for the weight matrix.
  b_init : initializer or None
      The initializer for the bias vector. If None, skip biases.
  in_channels : int
      The number of in channels.
  name : str
      A unique layer name.
  
  Examples
  --------
  With TensorLayer
  
  >>> net = tl.layers.InputLayer([5, 10, 10, 16], name='input')
  >>> offset1 = tl.layers.Conv2d(
  ...     n_filter=18, filter_size=(3, 3), strides=(1, 1), padding='SAME', name='offset1'
  ... )(net)
  >>> deformconv1 = tl.layers.DeformableConv2d(
  ...     offset_layer=offset1, n_filter=32, filter_size=(3, 3), name='deformable1'
  ... )(net)
  >>> offset2 = tl.layers.Conv2d(
  ...     n_filter=18, filter_size=(3, 3), strides=(1, 1), padding='SAME', name='offset2'
  ... )(deformconv1)
  >>> deformconv2 = tl.layers.DeformableConv2d(
  ...     offset_layer=offset2, n_filter=64, filter_size=(3, 3), name='deformable2'
  ... )(deformconv1)
  
  References
  ----------
  - The deformation operation was adapted from the implementation in `here <https://github.com/kastnerkyle/deform-conv>`__
  
  Notes
  -----
  - The padding is fixed to 'SAME'.
  - The current implementation is not optimized for memory usgae. Please use it carefully.
class_docstr_tok: ["The",":","class",":","`","DeformableConv2d","`","class","is","a","2D","`","Deformable","Convolutional","Networks","<","https",":","\/\/arxiv.org\/abs\/1703.06211",">","`","__",".","Parameters","--","--","--","--","--","offset_layer",":","tf.Tensor","To","predict","the","offset","of","convolution","operations",".","The","shape","is","(","batchsize",",","input","height",",","input","width",",","2","*","(","number","of","element","in","the","convolution","kernel",")",")","e.g",".","if","apply","a","3","*","3","kernel",",","the","number","of","the","last","dimension","should","be","18","(","2","*","3","*","3",")","n_filter",":","int","The","number","of","filters",".","filter_size",":","tuple","of","int","The","filter","size","(","height",",","width",")",".","act",":","activation","function","The","activation","function","of","this","layer",".","padding",":","str","The","padding","algorithm","type",":","``","SAME","''","or","``","VALID","''",".","W_init",":","initializer","The","initializer","for","the","weight","matrix",".","b_init",":","initializer","or","None","The","initializer","for","the","bias","vector",".","If","None",",","skip","biases",".","in_channels",":","int","The","number","of","in","channels",".","name",":","str","A","unique","layer","name",".","Examples","--","--","--","--","With","TensorLayer",">",">",">","net","=","tl.layers.InputLayer","(","[","5",",","10",",","10",",","16","]",",","name='input","'",")",">",">",">","offset1","=","tl.layers.Conv2d","(","...","n_filter=18",",","filter_size=","(","3",",","3",")",",","strides=","(","1",",","1",")",",","padding='SAME","'",",","name='offset1'","...",")","(","net",")",">",">",">","deformconv1","=","tl.layers.DeformableConv2d","(","...","offset_layer=offset1",",","n_filter=32",",","filter_size=","(","3",",","3",")",",","name='deformable1'","...",")","(","net",")",">",">",">","offset2","=","tl.layers.Conv2d","(","...","n_filter=18",",","filter_size=","(","3",",","3",")",",","strides=","(","1",",","1",")",",","padding='SAME","'",",","name='offset2'","...",")","(","deformconv1",")",">",">",">","deformconv2","=","tl.layers.DeformableConv2d","(","...","offset_layer=offset2",",","n_filter=64",",","filter_size=","(","3",",","3",")",",","name='deformable2'","...",")","(","deformconv1",")","References","--","--","--","--","--","-","The","deformation","operation","was","adapted","from","the","implementation","in","`","here","<","https",":","\/\/github.com\/kastnerkyle\/deform-conv",">","`","__","Notes","--","--","-","-","The","padding","is","fixed","to","'SAME","'",".","-","The","current","implementation","is","not","optimized","for","memory","usgae",".","Please","use","it","carefully","."]
code: def __init__(
      self,
      offset_layer=None,
      # shape=(3, 3, 1, 100),
      n_filter=32,
      filter_size=(3, 3),
      act=None,
      padding="SAME",
      W_init=tl.initializers.truncated_normal(stddev=0.02),
      b_init=tl.initializers.constant(value=0.0),
      in_channels=None,
      name=None,  # 'deformable_conv_2d',
  ):
      super().__init__(name, act=act)
  
      self.offset_layer = offset_layer
      self.n_filter = n_filter
      self.filter_size = filter_size
      self.padding = padding
      self.W_init = W_init
      self.b_init = b_init
      self.in_channels = in_channels
  
      self.kernel_n = filter_size[0] * filter_size[1]
      if self.offset_layer.get_shape()[-1] != 2 * self.kernel_n:
          raise AssertionError(
              "offset.get_shape()[-1] is not equal to: %d"
              % 2
              * self.kernel_n
          )
  
      logging.info(
          "DeformableConv2d %s: n_filter: %d, filter_size: %s act: %s"
          % (
              self.name,
              self.n_filter,
              str(self.filter_size),
              self.act.__name__
              if self.act is not None
              else "No Activation",
          )
      )
  
file_path: TensorLayer/tensorlayer/layers/convolution/deformable_conv.py
imports: import tensorflow
  import tensorlayer
  from tensorlayer import logging
  from tensorlayer.decorators import deprecated_alias, private_method
  from tensorlayer.layers.core import Layer
label_desc: Use image node_id 1 to create a new DeformableConv2d object from inherited base classes: Layer with example: obj = DeformableConv2d(offset_layer, n_filter, filter_size, act, padding, W_init, b_init, in_channels, name)