parameters: (inputs,
                   units,
                   num_blocks=None,
                   exclusive=False,
                   kernel_initializer=None,
                   reuse=None,
                   name=None,
                   *args,
                   **kwargs)
docstring: A autoregressively masked dense layer. Analogous to `tf.layers.dense`.
  
    See [1] for detailed explanation.
  
    [1]: "MADE: Masked Autoencoder for Distribution Estimation."
         Mathieu Germain, Karol Gregor, Iain Murray, Hugo Larochelle. ICML. 2015.
         https://arxiv.org/abs/1502.03509
  
    Arguments:
      inputs: Tensor input.
      units: Python `int` scalar representing the dimensionality of the output
        space.
      num_blocks: Python `int` scalar representing the number of blocks for the
        MADE masks.
      exclusive: Python `bool` scalar representing whether to zero the diagonal of
        the mask, used for the first layer of a MADE.
      kernel_initializer: Initializer function for the weight matrix.
        If `None` (default), weights are initialized using the
        `tf.glorot_random_initializer`.
      reuse: Python `bool` scalar representing whether to reuse the weights of a
        previous layer by the same name.
      name: Python `str` used to describe ops managed by this function.
      *args: `tf.layers.dense` arguments.
      **kwargs: `tf.layers.dense` keyword arguments.
  
    Returns:
      Output tensor.
  
    Raises:
      NotImplementedError: if rightmost dimension of `inputs` is unknown prior to
        graph execution.
docstring_summary: A autoregressively masked dense layer. Analogous to `tf.layers.dense`.
docstring_tokens: A autoregressively masked dense layer . Analogous to tf . layers . dense .
function: def masked_dense(inputs,
                   units,
                   num_blocks=None,
                   exclusive=False,
                   kernel_initializer=None,
                   reuse=None,
                   name=None,
                   *args,
                   **kwargs):
    """A autoregressively masked dense layer. Analogous to `tf.layers.dense`.
  
    See [1] for detailed explanation.
  
    [1]: "MADE: Masked Autoencoder for Distribution Estimation."
         Mathieu Germain, Karol Gregor, Iain Murray, Hugo Larochelle. ICML. 2015.
         https://arxiv.org/abs/1502.03509
  
    Arguments:
      inputs: Tensor input.
      units: Python `int` scalar representing the dimensionality of the output
        space.
      num_blocks: Python `int` scalar representing the number of blocks for the
        MADE masks.
      exclusive: Python `bool` scalar representing whether to zero the diagonal of
        the mask, used for the first layer of a MADE.
      kernel_initializer: Initializer function for the weight matrix.
        If `None` (default), weights are initialized using the
        `tf.glorot_random_initializer`.
      reuse: Python `bool` scalar representing whether to reuse the weights of a
        previous layer by the same name.
      name: Python `str` used to describe ops managed by this function.
      *args: `tf.layers.dense` arguments.
      **kwargs: `tf.layers.dense` keyword arguments.
  
    Returns:
      Output tensor.
  
    Raises:
      NotImplementedError: if rightmost dimension of `inputs` is unknown prior to
        graph execution.
    """
    # TODO(b/67594795): Better support of dynamic shape.
    input_depth = inputs.shape.with_rank_at_least(1)[-1].value
    if input_depth is None:
      raise NotImplementedError(
          "Rightmost dimension must be known prior to graph execution.")
  
    mask = _gen_mask(num_blocks, input_depth, units,
                     MASK_EXCLUSIVE if exclusive else MASK_INCLUSIVE).T
  
    if kernel_initializer is None:
      kernel_initializer = init_ops.glorot_normal_initializer()
  
    def masked_initializer(shape, dtype=None, partition_info=None):
      return mask * kernel_initializer(shape, dtype, partition_info)
  
    with ops.name_scope(name, "masked_dense", [inputs, units, num_blocks]):
      layer = layers.Dense(
          units,
          kernel_initializer=masked_initializer,
          kernel_constraint=lambda x: mask * x,
          name=name,
          dtype=inputs.dtype.base_dtype,
          _scope=name,
          _reuse=reuse,
          *args,
          **kwargs)
      return layer.apply(inputs)
function_tokens: def masked_dense ( inputs , units , num_blocks = None , exclusive = False , kernel_initializer = None , reuse = None , name = None , * args , * * kwargs ) : # TODO(b/67594795): Better support of dynamic shape. input_depth = inputs . shape . with_rank_at_least ( 1 ) [ - 1 ] . value if input_depth is None : raise NotImplementedError ( "Rightmost dimension must be known prior to graph execution." ) mask = _gen_mask ( num_blocks , input_depth , units , MASK_EXCLUSIVE if exclusive else MASK_INCLUSIVE ) . T if kernel_initializer is None : kernel_initializer = init_ops . glorot_normal_initializer ( ) def masked_initializer ( shape , dtype = None , partition_info = None ) : return mask * kernel_initializer ( shape , dtype , partition_info ) with ops . name_scope ( name , "masked_dense" , [ inputs , units , num_blocks ] ) : layer = layers . Dense ( units , kernel_initializer = masked_initializer , kernel_constraint = lambda x : mask * x , name = name , dtype = inputs . dtype . base_dtype , _scope = name , _reuse = reuse , * args , * * kwargs ) return layer . apply ( inputs )