parameters: (inp,
                    depth,
                    width=3,
                    rate=1,
                    context=None,
                    scope=None,
                    reuse=None)
docstring: Single wavenet layer.
  
    This assumes that the input is a rank 4 tensor of shape:
      [batch, reduced_text_dimension, auxilliary_text_dimension, feature_depth]
    If rate is more than one, this will be reshaped to
      [B, R//(2**(rate-1)), A*(2**(rate-1)), D]
    Then a conv2d will be applied with kernel size [width, 1].
  
    The rest of the wavenet activations will be applied and the result will be
    returned without reshaping, this allows a multilayer wavenet to be implemented
    by subsequent calls to wavenet_layer and rate=2.
  
    Arguments:
      inp: input tensor
      depth: depth of the intermediate nonlinear activations before reduced.
      width: the width of the conv filter, 2 by default.
      rate: the dilation, use 1 in the first layer and 2 in subsequent layers.
      context: Optional 2-D [batch, dim] tensor on which to condition each node.
      scope: name of scope if given.
      reuse: reuse for variable scope if given.
  
    Returns:
      output: output tensor.
docstring_summary: Single wavenet layer.
docstring_tokens: Single wavenet layer .
function: def wavenet_layer(inp,
                    depth,
                    width=3,
                    rate=1,
                    context=None,
                    scope=None,
                    reuse=None):
    """Single wavenet layer.
  
    This assumes that the input is a rank 4 tensor of shape:
      [batch, reduced_text_dimension, auxilliary_text_dimension, feature_depth]
    If rate is more than one, this will be reshaped to
      [B, R//(2**(rate-1)), A*(2**(rate-1)), D]
    Then a conv2d will be applied with kernel size [width, 1].
  
    The rest of the wavenet activations will be applied and the result will be
    returned without reshaping, this allows a multilayer wavenet to be implemented
    by subsequent calls to wavenet_layer and rate=2.
  
    Arguments:
      inp: input tensor
      depth: depth of the intermediate nonlinear activations before reduced.
      width: the width of the conv filter, 2 by default.
      rate: the dilation, use 1 in the first layer and 2 in subsequent layers.
      context: Optional 2-D [batch, dim] tensor on which to condition each node.
      scope: name of scope if given.
      reuse: reuse for variable scope if given.
  
    Returns:
      output: output tensor.
    """
    tf.logging.info('Creating wavenet layer d=%d w=%d r=%d', depth, width, rate)
    with tf.variable_scope(scope, 'wavenet_layer', [inp], reuse=reuse):
      current_shape = inp.get_shape()
      true_shape = tf.shape(inp)
      in_depth = current_shape[3].value
      mul = 2**(rate - 1)
      reshaped = tf.reshape(
          inp,
          [true_shape[0], true_shape[1] // mul, mul * true_shape[2], in_depth])
  
      conved = slim.conv2d(
          reshaped,
          2 * depth, [width, 1],
          rate=1,
          padding='SAME',
          activation_fn=None)
      if context is not None:
        conved += layers.linear(context, 2 * depth)[:, None, None, :]
  
      act = tf.nn.tanh(conved[:, :, :, :depth])
      gate = tf.nn.sigmoid(conved[:, :, :, depth:])
  
      z = act * gate
  
      if in_depth != depth:
        z = slim.conv2d(z, in_depth, [1, 1], padding='SAME', activation_fn=None)
  
      return z + reshaped
function_tokens: def wavenet_layer ( inp , depth , width = 3 , rate = 1 , context = None , scope = None , reuse = None ) : tf . logging . info ( 'Creating wavenet layer d=%d w=%d r=%d' , depth , width , rate ) with tf . variable_scope ( scope , 'wavenet_layer' , [ inp ] , reuse = reuse ) : current_shape = inp . get_shape ( ) true_shape = tf . shape ( inp ) in_depth = current_shape [ 3 ] . value mul = 2 ** ( rate - 1 ) reshaped = tf . reshape ( inp , [ true_shape [ 0 ] , true_shape [ 1 ] // mul , mul * true_shape [ 2 ] , in_depth ] ) conved = slim . conv2d ( reshaped , 2 * depth , [ width , 1 ] , rate = 1 , padding = 'SAME' , activation_fn = None ) if context is not None : conved += layers . linear ( context , 2 * depth ) [ : , None , None , : ] act = tf . nn . tanh ( conved [ : , : , : , : depth ] ) gate = tf . nn . sigmoid ( conved [ : , : , : , depth : ] ) z = act * gate if in_depth != depth : z = slim . conv2d ( z , in_depth , [ 1 , 1 ] , padding = 'SAME' , activation_fn = None ) return z + reshaped