class_docstr: A multi-layer perceptron module.
docstr: Returns a new MLP which is the layer-wise reverse of this MLP.
  
  NOTE: Since computing the reverse of an MLP requires knowing the input size
  of each linear layer this method will fail if the module has not been called
  at least once. See `snt.Deferred` as a possible solution to this problem.
  
  The contract of reverse is that the reversed module will accept the output
  of the parent module as input and produce an output which is the input size
  of the parent.
  
  >>> mlp = snt.nets.MLP([1, 2, 3])
  >>> y = mlp(tf.ones([1, 2]))
  >>> rev = mlp.reverse()
  >>> rev(y)
  <tf.Tensor: shape=(1, 2), ...>
  
  Args:
    activate_final: Whether the final layer of the MLP should be activated.
    name: Optional name for the new module. The default name will be the name
      of the current module prefixed with ``"reversed_"``.
  
  Returns:
    An MLP instance which is the reverse of the current instance. Note these
    instances do not share weights and, apart from being symmetric to each
    other, are not coupled in any way.
code: def reverse(
      self,
      activate_final: Optional[bool] = None,
      name: Optional[str] = None,
  ) -> "MLP":
      """Returns a new MLP which is the layer-wise reverse of this MLP.
  
      NOTE: Since computing the reverse of an MLP requires knowing the input size
      of each linear layer this method will fail if the module has not been called
      at least once. See `snt.Deferred` as a possible solution to this problem.
  
      The contract of reverse is that the reversed module will accept the output
      of the parent module as input and produce an output which is the input size
      of the parent.
  
      >>> mlp = snt.nets.MLP([1, 2, 3])
      >>> y = mlp(tf.ones([1, 2]))
      >>> rev = mlp.reverse()
      >>> rev(y)
      <tf.Tensor: shape=(1, 2), ...>
  
      Args:
        activate_final: Whether the final layer of the MLP should be activated.
        name: Optional name for the new module. The default name will be the name
          of the current module prefixed with ``"reversed_"``.
  
      Returns:
        An MLP instance which is the reverse of the current instance. Note these
        instances do not share weights and, apart from being symmetric to each
        other, are not coupled in any way.
      """
  
      if activate_final is None:
          activate_final = self._activate_final
      if name is None:
          name = self.name + "_reversed"
  
      return MLP(
          output_sizes=(
              layer.input_size for layer in reversed(self.submodules)
          ),
          w_init=self._w_init,
          b_init=self._b_init,
          with_bias=self._with_bias,
          activation=self._activation,
          dropout_rate=self._dropout_rate,
          activate_final=activate_final,
          name=name,
      )
  
file_path: sonnet/sonnet/src/nets/mlp.py
imports: from typing import Callable, Iterable, Optional
  from sonnet.src import base
  from sonnet.src import initializers
  from sonnet.src import linear
  import tensorflow
label_desc: Use image node_id 3 for calling the MLP obj's underlying member method code with example usage: obj.reverse(activate_final, name) and returns: MLP