def _build(self, inputs, is_training=True, dropout_keep_prob=0.5):
    """Assembles the `MLP` and connects it to the graph.

    Args:
      inputs: A 2D Tensor of size `[batch_size, input_size]`.
      is_training: A bool or tf.Bool Tensor. Indicates whether we are
        currently training. Defaults to `True`.
      dropout_keep_prob: The probability that each element is kept when
        both `use_dropout` and `is_training` are True. Defaults to 0.5.
    Returns:
      A 2D Tensor of size `[batch_size, output_sizes[-1]]`.
    """
    self._input_shape = tuple(inputs.get_shape().as_list())
    net = inputs

    final_index = self._num_layers - 1
    for layer_id in xrange(self._num_layers):
      net = self._layers[layer_id](net)

      if final_index != layer_id or self._activate_final:
        # Only perform dropout whenever we are activating the layer's outputs.
        if self._use_dropout:
          keep_prob = utils.smart_cond(
              is_training, true_fn=lambda: dropout_keep_prob,
              false_fn=lambda: tf.constant(1.0)
          )
          net = tf.nn.dropout(net, keep_prob=keep_prob)
        net = self._activation(net)

    return net
def _build ( self , inputs , is_training = True , dropout_keep_prob = 0.5 ) : self . _input_shape = tuple ( inputs . get_shape ( ) . as_list ( ) ) net = inputs final_index = self . _num_layers - 1 for layer_id in xrange ( self . _num_layers ) : net = self . _layers [ layer_id ] ( net ) if final_index != layer_id or self . _activate_final : if self . _use_dropout : keep_prob = utils . smart_cond ( is_training , true_fn = lambda : dropout_keep_prob , false_fn = lambda : tf . constant ( 1.0 ) ) net = tf . nn . dropout ( net , keep_prob = keep_prob ) net = self . _activation ( net ) return net
Assembles the `MLP` and connects it to the graph.

    Args:
      inputs: A 2D Tensor of size `[batch_size, input_size]`.
      is_training: A bool or tf.Bool Tensor. Indicates whether we are
        currently training. Defaults to `True`.
      dropout_keep_prob: The probability that each element is kept when
        both `use_dropout` and `is_training` are True. Defaults to 0.5.
    Returns:
      A 2D Tensor of size `[batch_size, output_sizes[-1]]`.