(x, hparams, is_training=True, reuse=False)
return z
Autoencoder encoder network.

  Args:
    x: Tensor. The observed variables.
    hparams: HParams. Hyperparameters.
    is_training: bool. Whether batch normalization should be computed in
        training mode. Defaults to True.
    reuse: bool. Whether the variable scope should be reused.
        Defaults to False.

  Returns:
    The output of the encoder, i.e. a synthetic z computed from x.
Autoencoder encoder network.
Autoencoder encoder network .
def encode(x, hparams, is_training=True, reuse=False):
  """Autoencoder encoder network.

  Args:
    x: Tensor. The observed variables.
    hparams: HParams. Hyperparameters.
    is_training: bool. Whether batch normalization should be computed in
        training mode. Defaults to True.
    reuse: bool. Whether the variable scope should be reused.
        Defaults to False.

  Returns:
    The output of the encoder, i.e. a synthetic z computed from x.
  """
  with tf.variable_scope("encoder", reuse=reuse):
    h = utils.conv2d(
        x, [5, 5], [2, 2],
        128,
        is_training,
        activation_fn=utils.leaky_relu(),
        batch_norm=True,
        scope="0")
    h = utils.conv2d(
        h, [4, 4], [2, 2],
        128,
        is_training,
        activation_fn=utils.leaky_relu(),
        batch_norm=True,
        scope="1")
    h = utils.conv2d(
        h, [4, 4], [2, 2],
        128,
        is_training,
        activation_fn=utils.leaky_relu(),
        batch_norm=True,
        scope="2")
    h = utils.conv2d(
        h, [4, 4], [2, 2],
        256,
        is_training,
        activation_fn=utils.leaky_relu(),
        batch_norm=True,
        scope="3")
    h = utils.conv2d(
        h, [4, 4], [2, 2],
        256,
        is_training,
        activation_fn=utils.leaky_relu(),
        batch_norm=True,
        scope="4")
    h = utils.conv2d(
        h, [4, 4], [2, 2],
        256,
        is_training,
        activation_fn=utils.leaky_relu(),
        batch_norm=True,
        scope="5")
    h = utils.conv2d(
        h, [4, 4], [2, 2],
        512,
        is_training,
        activation_fn=utils.leaky_relu(),
        batch_norm=True,
        scope="6")
    h = utils.conv2d(
        h, [4, 4], [2, 2],
        512,
        is_training,
        activation_fn=utils.leaky_relu(),
        batch_norm=True,
        scope="7")
    h = utils.conv2d(
        h, [4, 4], [2, 1],
        512,
        is_training,
        activation_fn=utils.leaky_relu(),
        batch_norm=True,
        scope="7_1")
    h = utils.conv2d(
        h, [1, 1], [1, 1],
        1024,
        is_training,
        activation_fn=utils.leaky_relu(),
        batch_norm=True,
        scope="8")

    z = utils.conv2d(
        h, [1, 1], [1, 1],
        hparams.num_latent,
        is_training,
        activation_fn=None,
        batch_norm=True,
        scope="z")
  return z
def encode ( x , hparams , is_training = True , reuse = False ) : with tf . variable_scope ( "encoder" , reuse = reuse ) : h = utils . conv2d ( x , [ 5 , 5 ] , [ 2 , 2 ] , 128 , is_training , activation_fn = utils . leaky_relu ( ) , batch_norm = True , scope = "0" ) h = utils . conv2d ( h , [ 4 , 4 ] , [ 2 , 2 ] , 128 , is_training , activation_fn = utils . leaky_relu ( ) , batch_norm = True , scope = "1" ) h = utils . conv2d ( h , [ 4 , 4 ] , [ 2 , 2 ] , 128 , is_training , activation_fn = utils . leaky_relu ( ) , batch_norm = True , scope = "2" ) h = utils . conv2d ( h , [ 4 , 4 ] , [ 2 , 2 ] , 256 , is_training , activation_fn = utils . leaky_relu ( ) , batch_norm = True , scope = "3" ) h = utils . conv2d ( h , [ 4 , 4 ] , [ 2 , 2 ] , 256 , is_training , activation_fn = utils . leaky_relu ( ) , batch_norm = True , scope = "4" ) h = utils . conv2d ( h , [ 4 , 4 ] , [ 2 , 2 ] , 256 , is_training , activation_fn = utils . leaky_relu ( ) , batch_norm = True , scope = "5" ) h = utils . conv2d ( h , [ 4 , 4 ] , [ 2 , 2 ] , 512 , is_training , activation_fn = utils . leaky_relu ( ) , batch_norm = True , scope = "6" ) h = utils . conv2d ( h , [ 4 , 4 ] , [ 2 , 2 ] , 512 , is_training , activation_fn = utils . leaky_relu ( ) , batch_norm = True , scope = "7" ) h = utils . conv2d ( h , [ 4 , 4 ] , [ 2 , 1 ] , 512 , is_training , activation_fn = utils . leaky_relu ( ) , batch_norm = True , scope = "7_1" ) h = utils . conv2d ( h , [ 1 , 1 ] , [ 1 , 1 ] , 1024 , is_training , activation_fn = utils . leaky_relu ( ) , batch_norm = True , scope = "8" ) z = utils . conv2d ( h , [ 1 , 1 ] , [ 1 , 1 ] , hparams . num_latent , is_training , activation_fn = None , batch_norm = True , scope = "z" ) return z