original_docstring: Generator network for DCGAN.
  
    Construct generator network from inputs to the final endpoint.
  
    Args:
      inputs: A tensor with any size N. [batch_size, N]
      depth: Number of channels in last deconvolution layer.
      final_size: The shape of the final output.
      num_outputs: Number of output features. For images, this is the number of
        channels.
      is_training: whether is training or not.
      reuse: Whether or not the network has its variables should be reused. scope
        must be given to be reused.
      scope: Optional variable_scope.
      fused_batch_norm: If `True`, use a faster, fused implementation of
        batch norm.
  
    Returns:
      logits: the pre-softmax activations, a tensor of size
        [batch_size, 32, 32, channels]
      end_points: a dictionary from components of the network to their activation.
  
    Raises:
      ValueError: If `inputs` is not 2-dimensional.
      ValueError: If `final_size` isn't a power of 2 or is less than 8.
    
docstring: Generator network for DCGAN.
  Construct generator network from inputs to the final endpoint.
docstring_tokens: Generator network for DCGAN . Construct generator network from inputs to the final endpoint .
code: def generator(inputs,
                depth=64,
                final_size=32,
                num_outputs=3,
                is_training=True,
                reuse=None,
                scope='Generator',
                fused_batch_norm=False):
    """Generator network for DCGAN.
  
    Construct generator network from inputs to the final endpoint.
  
    Args:
      inputs: A tensor with any size N. [batch_size, N]
      depth: Number of channels in last deconvolution layer.
      final_size: The shape of the final output.
      num_outputs: Number of output features. For images, this is the number of
        channels.
      is_training: whether is training or not.
      reuse: Whether or not the network has its variables should be reused. scope
        must be given to be reused.
      scope: Optional variable_scope.
      fused_batch_norm: If `True`, use a faster, fused implementation of
        batch norm.
  
    Returns:
      logits: the pre-softmax activations, a tensor of size
        [batch_size, 32, 32, channels]
      end_points: a dictionary from components of the network to their activation.
  
    Raises:
      ValueError: If `inputs` is not 2-dimensional.
      ValueError: If `final_size` isn't a power of 2 or is less than 8.
    """
    normalizer_fn = slim.batch_norm
    normalizer_fn_args = {
        'is_training': is_training,
        'zero_debias_moving_mean': True,
        'fused': fused_batch_norm,
    }
  
    inputs.get_shape().assert_has_rank(2)
    if log(final_size, 2) != int(log(final_size, 2)):
      raise ValueError('`final_size` (%i) must be a power of 2.' % final_size)
    if final_size < 8:
      raise ValueError('`final_size` (%i) must be greater than 8.' % final_size)
  
    end_points = {}
    num_layers = int(log(final_size, 2)) - 1
    with tf.variable_scope(
        scope, values=[inputs], reuse=reuse) as scope:
      with slim.arg_scope([normalizer_fn], **normalizer_fn_args):
        with slim.arg_scope([slim.conv2d_transpose],
                            normalizer_fn=normalizer_fn,
                            stride=2,
                            kernel_size=4):
          net = tf.expand_dims(tf.expand_dims(inputs, 1), 1)
  
          # First upscaling is different because it takes the input vector.
          current_depth = depth * 2 ** (num_layers - 1)
          scope = 'deconv1'
          net = slim.conv2d_transpose(
              net, current_depth, stride=1, padding='VALID', scope=scope)
          end_points[scope] = net
  
          for i in xrange(2, num_layers):
            scope = 'deconv%i' % (i)
            current_depth = depth * 2 ** (num_layers - i)
            net = slim.conv2d_transpose(net, current_depth, scope=scope)
            end_points[scope] = net
  
          # Last layer has different normalizer and activation.
          scope = 'deconv%i' % (num_layers)
          net = slim.conv2d_transpose(
              net, depth, normalizer_fn=None, activation_fn=None, scope=scope)
          end_points[scope] = net
  
          # Convert to proper channels.
          scope = 'logits'
          logits = slim.conv2d(
              net,
              num_outputs,
              normalizer_fn=None,
              activation_fn=None,
              kernel_size=1,
              stride=1,
              padding='VALID',
              scope=scope)
          end_points[scope] = logits
  
          logits.get_shape().assert_has_rank(4)
          logits.get_shape().assert_is_compatible_with(
              [None, final_size, final_size, num_outputs])
  
          return logits, end_points
code_tokens: def generator ( inputs , depth = 64 , final_size = 32 , num_outputs = 3 , is_training = True , reuse = None , scope = 'Generator' , fused_batch_norm = False ) : normalizer_fn = slim . batch_norm normalizer_fn_args = { 'is_training' : is_training , 'zero_debias_moving_mean' : True , 'fused' : fused_batch_norm , } inputs . get_shape ( ) . assert_has_rank ( 2 ) if log ( final_size , 2 ) != int ( log ( final_size , 2 ) ) : raise ValueError ( '`final_size` (%i) must be a power of 2.' % final_size ) if final_size < 8 : raise ValueError ( '`final_size` (%i) must be greater than 8.' % final_size ) end_points = { } num_layers = int ( log ( final_size , 2 ) ) - 1 with tf . variable_scope ( scope , values = [ inputs ] , reuse = reuse ) as scope : with slim . arg_scope ( [ normalizer_fn ] , ** normalizer_fn_args ) : with slim . arg_scope ( [ slim . conv2d_transpose ] , normalizer_fn = normalizer_fn , stride = 2 , kernel_size = 4 ) : net = tf . expand_dims ( tf . expand_dims ( inputs , 1 ) , 1 ) current_depth = depth * 2 ** ( num_layers - 1 ) scope = 'deconv1' net = slim . conv2d_transpose ( net , current_depth , stride = 1 , padding = 'VALID' , scope = scope ) end_points [ scope ] = net for i in xrange ( 2 , num_layers ) : scope = 'deconv%i' % ( i ) current_depth = depth * 2 ** ( num_layers - i ) net = slim . conv2d_transpose ( net , current_depth , scope = scope ) end_points [ scope ] = net scope = 'deconv%i' % ( num_layers ) net = slim . conv2d_transpose ( net , depth , normalizer_fn = None , activation_fn = None , scope = scope ) end_points [ scope ] = net scope = 'logits' logits = slim . conv2d ( net , num_outputs , normalizer_fn = None , activation_fn = None , kernel_size = 1 , stride = 1 , padding = 'VALID' , scope = scope ) end_points [ scope ] = logits logits . get_shape ( ) . assert_has_rank ( 4 ) logits . get_shape ( ) . assert_is_compatible_with ( [ None , final_size , final_size , num_outputs ] ) return logits , end_points
short_docstring: Generator network for DCGAN.
short_docstring_tokens: Generator network for DCGAN .
comment: """Generator network for DCGAN.
  
    Construct generator network from inputs to the final endpoint.
  
    Args:
      inputs: A tensor with any size N. [batch_size, N]
      depth: Number of channels in last deconvolution layer.
      final_size: The shape of the final output.
      num_outputs: Number of output features. For images, this is the number of
        channels.
      is_training: whether is training or not.
      reuse: Whether or not the network has its variables should be reused. scope
        must be given to be reused.
      scope: Optional variable_scope.
      fused_batch_norm: If `True`, use a faster, fused implementation of
        batch norm.
  
    Returns:
      logits: the pre-softmax activations, a tensor of size
        [batch_size, 32, 32, channels]
      end_points: a dictionary from components of the network to their activation.
  
    Raises:
      ValueError: If `inputs` is not 2-dimensional.
      ValueError: If `final_size` isn't a power of 2 or is less than 8.
    """$SEP$# First upscaling is different because it takes the input vector.$SEP$# Last layer has different normalizer and activation.$SEP$# Convert to proper channels.