def _transpose(self,
                 transpose_constructor,
                 name=None,
                 output_channels=None,
                 kernel_shapes=None,
                 strides=None,
                 paddings=None,
                 activation=None,
                 activate_final=None,
                 normalization_ctor=None,
                 normalization_kwargs=None,
                 normalize_final=None,
                 initializers=None,
                 partitioners=None,
                 regularizers=None,
                 use_bias=None,
                 data_format=None):
    """Returns transposed version of this network.

    Args:
      transpose_constructor: A method that creates an instance of the transposed
        network type. The method must accept the same kwargs as this methods
        with the exception of the `transpose_constructor` argument.
      name: Optional string specifying the name of the transposed module. The
        default name is constructed by appending "_transpose"
        to `self.module_name`.
      output_channels: Optional iterable of numbers of output channels.
      kernel_shapes: Optional iterable of kernel sizes. The default value is
        constructed by reversing `self.kernel_shapes`.
      strides: Optional iterable of kernel strides. The default value is
        constructed by reversing `self.strides`.
      paddings: Optional iterable of padding options, either `snt.SAME` or
        `snt.VALID`; The default value is constructed by reversing
        `self.paddings`.
      activation: Optional activation op. Default value is `self.activation`.
      activate_final: Optional boolean determining if the activation and batch
        normalization, if turned on, are applied to the final layer.
      normalization_ctor: Constructor to return a callable which will perform
        normalization at each layer. Defaults to None / no normalization.
        Examples of what could go here: `snt.BatchNormV2`, `snt.LayerNorm`. If
        a string is provided, importlib is used to convert the string to a
        callable, so either `snt.LayerNorm` or `"snt.LayerNorm"` can be
        provided.
      normalization_kwargs: kwargs to be provided to `normalization_ctor` when
        it is called.
      normalize_final: Whether to apply normalization after the final conv
        layer. Default is to take the value of activate_final.
      initializers: Optional dict containing ops to initialize the filters of
        the whole network (with key 'w') or biases (with key 'b'). The default
        value is `self.initializers`.
      partitioners: Optional dict containing partitioners to partition
        weights (with key 'w') or biases (with key 'b'). The default value is
        `self.partitioners`.
      regularizers: Optional dict containing regularizers for the filters of the
        whole network (with key 'w') or biases (with key 'b'). The default is
        `self.regularizers`.
      use_bias: Optional boolean or iterable of booleans determining whether to
        include bias parameters in the convolutional layers. Default
        is constructed by reversing `self.use_bias`.
      data_format: Optional string, one of "NCHW" or "NHWC". Specifies whether
        the channel dimension of the input and output is the last dimension.
        Default is `self._data_format`.
    Returns:
      Matching transposed module.

    Raises:
      ValueError: If output_channels is specified and its length does not match
        the number of layers.
    """

    if data_format is None:
      data_format = self._data_format

    if output_channels is None:
      output_channels = []
      channel_dim = -1 if data_format == DATA_FORMAT_NHWC else 1
      for layer in reversed(self._layers):
        output_channels.append(lambda l=layer: l.input_shape[channel_dim])

    elif len(output_channels) != len(self._layers):
      # Note that we only have to do this check for the output channels. Any
      # other inconsistencies will be picked up by ConvNet2D.__init__.
      raise ValueError("Iterable output_channels length must match the "
                       "number of layers ({}), but is {} instead.".format(
                           len(self._layers), len(output_channels)))

    if kernel_shapes is None:
      kernel_shapes = reversed(self.kernel_shapes)

    if strides is None:
      strides = reversed(self.strides)

    if paddings is None:
      paddings = reversed(self.paddings)

    if activation is None:
      activation = self.activation

    if activate_final is None:
      activate_final = self.activate_final

    if normalization_ctor is None:
      normalization_ctor = self.normalization_ctor

    if normalization_kwargs is None:
      normalization_kwargs = self.normalization_kwargs

    if normalize_final is None:
      normalize_final = self.normalize_final

    if initializers is None:
      initializers = self.initializers

    if partitioners is None:
      partitioners = self.partitioners

    if regularizers is None:
      regularizers = self.regularizers

    if use_bias is None:
      use_bias = reversed(self.use_bias)

    if name is None:
      name = self.module_name + "_transpose"

    return transpose_constructor(
        output_channels=output_channels,
        kernel_shapes=kernel_shapes,
        strides=strides,
        paddings=paddings,
        activation=activation,
        activate_final=activate_final,
        normalization_ctor=normalization_ctor,
        normalization_kwargs=normalization_kwargs,
        normalize_final=normalize_final,
        initializers=initializers,
        partitioners=partitioners,
        regularizers=regularizers,
        use_bias=use_bias,
        data_format=data_format,
        name=name)
def _transpose ( self , transpose_constructor , name = None , output_channels = None , kernel_shapes = None , strides = None , paddings = None , activation = None , activate_final = None , normalization_ctor = None , normalization_kwargs = None , normalize_final = None , initializers = None , partitioners = None , regularizers = None , use_bias = None , data_format = None ) : if data_format is None : data_format = self . _data_format if output_channels is None : output_channels = [ ] channel_dim = - 1 if data_format == DATA_FORMAT_NHWC else 1 for layer in reversed ( self . _layers ) : output_channels . append ( lambda l = layer : l . input_shape [ channel_dim ] ) elif len ( output_channels ) != len ( self . _layers ) : raise ValueError ( "Iterable output_channels length must match the " "number of layers ({}), but is {} instead." . format ( len ( self . _layers ) , len ( output_channels ) ) ) if kernel_shapes is None : kernel_shapes = reversed ( self . kernel_shapes ) if strides is None : strides = reversed ( self . strides ) if paddings is None : paddings = reversed ( self . paddings ) if activation is None : activation = self . activation if activate_final is None : activate_final = self . activate_final if normalization_ctor is None : normalization_ctor = self . normalization_ctor if normalization_kwargs is None : normalization_kwargs = self . normalization_kwargs if normalize_final is None : normalize_final = self . normalize_final if initializers is None : initializers = self . initializers if partitioners is None : partitioners = self . partitioners if regularizers is None : regularizers = self . regularizers if use_bias is None : use_bias = reversed ( self . use_bias ) if name is None : name = self . module_name + "_transpose" return transpose_constructor ( output_channels = output_channels , kernel_shapes = kernel_shapes , strides = strides , paddings = paddings , activation = activation , activate_final = activate_final , normalization_ctor = normalization_ctor , normalization_kwargs = normalization_kwargs , normalize_final = normalize_final , initializers = initializers , partitioners = partitioners , regularizers = regularizers , use_bias = use_bias , data_format = data_format , name = name )
Returns transposed version of this network.

    Args:
      transpose_constructor: A method that creates an instance of the transposed
        network type. The method must accept the same kwargs as this methods
        with the exception of the `transpose_constructor` argument.
      name: Optional string specifying the name of the transposed module. The
        default name is constructed by appending "_transpose"
        to `self.module_name`.
      output_channels: Optional iterable of numbers of output channels.
      kernel_shapes: Optional iterable of kernel sizes. The default value is
        constructed by reversing `self.kernel_shapes`.
      strides: Optional iterable of kernel strides. The default value is
        constructed by reversing `self.strides`.
      paddings: Optional iterable of padding options, either `snt.SAME` or
        `snt.VALID`; The default value is constructed by reversing
        `self.paddings`.
      activation: Optional activation op. Default value is `self.activation`.
      activate_final: Optional boolean determining if the activation and batch
        normalization, if turned on, are applied to the final layer.
      normalization_ctor: Constructor to return a callable which will perform
        normalization at each layer. Defaults to None / no normalization.
        Examples of what could go here: `snt.BatchNormV2`, `snt.LayerNorm`. If
        a string is provided, importlib is used to convert the string to a
        callable, so either `snt.LayerNorm` or `"snt.LayerNorm"` can be
        provided.
      normalization_kwargs: kwargs to be provided to `normalization_ctor` when
        it is called.
      normalize_final: Whether to apply normalization after the final conv
        layer. Default is to take the value of activate_final.
      initializers: Optional dict containing ops to initialize the filters of
        the whole network (with key 'w') or biases (with key 'b'). The default
        value is `self.initializers`.
      partitioners: Optional dict containing partitioners to partition
        weights (with key 'w') or biases (with key 'b'). The default value is
        `self.partitioners`.
      regularizers: Optional dict containing regularizers for the filters of the
        whole network (with key 'w') or biases (with key 'b'). The default is
        `self.regularizers`.
      use_bias: Optional boolean or iterable of booleans determining whether to
        include bias parameters in the convolutional layers. Default
        is constructed by reversing `self.use_bias`.
      data_format: Optional string, one of "NCHW" or "NHWC". Specifies whether
        the channel dimension of the input and output is the last dimension.
        Default is `self._data_format`.
    Returns:
      Matching transposed module.

    Raises:
      ValueError: If output_channels is specified and its length does not match
        the number of layers.