class_docstr: The :class:`SpatialTransformer2dAffine` class is a 2D `Spatial Transformer Layer <https://arxiv.org/abs/1506.02025>`__ for
  `2D Affine Transformation <https://en.wikipedia.org/wiki/Affine_transformation>`__.
  
  Parameters
  -----------
  out_size : tuple of int or None
      - The size of the output of the network (height, width), the feature maps will be resized by this.
  in_channels : int
      The number of in channels.
  data_format : str
      "channel_last" (NHWC, default) or "channels_first" (NCHW).
  name : str
      - A unique layer name.
  
  References
  -----------
  - `Spatial Transformer Networks <https://arxiv.org/abs/1506.02025>`__
  - `TensorFlow/Models <https://github.com/tensorflow/models/tree/master/transformer>`__
class_docstr_tok: ["The",":","class",":","`","SpatialTransformer2dAffine","`","class","is","a","2D","`","Spatial","Transformer","Layer","<","https",":","\/\/arxiv.org\/abs\/1506.02025",">","`","__","for","`","2D","Affine","Transformation","<","https",":","\/\/en.wikipedia.org\/wiki\/Affine_transformation",">","`","__",".","Parameters","--","--","--","--","--","-","out_size",":","tuple","of","int","or","None","-","The","size","of","the","output","of","the","network","(","height",",","width",")",",","the","feature","maps","will","be","resized","by","this",".","in_channels",":","int","The","number","of","in","channels",".","data_format",":","str","``","channel_last","''","(","NHWC",",","default",")","or","``","channels_first","''","(","NCHW",")",".","name",":","str","-","A","unique","layer","name",".","References","--","--","--","--","--","-","-","`","Spatial","Transformer","Networks","<","https",":","\/\/arxiv.org\/abs\/1506.02025",">","`","__","-","`","TensorFlow\/Models","<","https",":","\/\/github.com\/tensorflow\/models\/tree\/master\/transformer",">","`","__"]
code: def build(self, inputs_shape):
      if self.in_channels is None and len(inputs_shape) != 2:
          raise AssertionError(
              "The dimension of theta layer input must be rank 2, please reshape or flatten it"
          )
      if self.in_channels:
          shape = [self.in_channels, 6]
      else:
          # self.in_channels = inputs_shape[1]    # BUG
          # shape = [inputs_shape[1], 6]
          self.in_channels = inputs_shape[0][-1]  # zsdonghao
          shape = [self.in_channels, 6]
      self.W = self._get_weights(
          "weights", shape=tuple(shape), init=tl.initializers.Zeros()
      )
      identity = np.reshape(
          np.array([[1, 0, 0], [0, 1, 0]], dtype=np.float32),
          newshape=(6,),
      )
      self.b = self._get_weights(
          "biases", shape=(6,), init=tl.initializers.Constant(identity)
      )
  
file_path: TensorLayer/tensorlayer/layers/spatial_transformer.py
imports: import numpy
  import tensorflow
  from six.moves import xrange
  from tensorflow.python.ops import array_ops
  import tensorlayer
  from tensorlayer import logging
  from tensorlayer.decorators import deprecated_alias
  from tensorlayer.layers.core import Layer
  from tensorlayer.layers.utils import flatten_reshape
label_desc: Use image node_id 3 for calling the SpatialTransformer2dAffine obj's underlying member method code with example usage: obj.build(inputs_shape) without return types