(
    latent_signal,
    layer_sizes=[],
    b_norm=True,
    b_norm_decay=0.9,
    non_linearity=tf.nn.relu,
    regularizer=None,
    weight_decay=0.001,
    reuse=False,
    scope=None,
    dropout_prob=None,
    b_norm_finish=False,
    b_norm_decay_finish=0.9,
    verbose=False,
)
return layer
A decoding network which maps points from the latent space back onto the data space.
A decoding network which maps points from the latent space back onto the data space.
A decoding network which maps points from the latent space back onto the data space .
def decoder_with_fc_only(
    latent_signal,
    layer_sizes=[],
    b_norm=True,
    b_norm_decay=0.9,
    non_linearity=tf.nn.relu,
    regularizer=None,
    weight_decay=0.001,
    reuse=False,
    scope=None,
    dropout_prob=None,
    b_norm_finish=False,
    b_norm_decay_finish=0.9,
    verbose=False,
):
    """A decoding network which maps points from the latent space back onto the data space.
    """
    if verbose:
        print("Building Decoder")

    n_layers = len(layer_sizes)
    dropout_prob = replicate_parameter_for_all_layers(dropout_prob, n_layers)

    if n_layers < 2:
        raise ValueError("For an FC decoder with single a layer use simpler code.")

    for i in range(0, n_layers - 1):
        name = "decoder_fc_" + str(i)
        scope_i = expand_scope_by_name(scope, name)

        if i == 0:
            layer = latent_signal

        layer = fully_connected(
            layer,
            layer_sizes[i],
            activation="linear",
            weights_init="xavier",
            name=name,
            regularizer=regularizer,
            weight_decay=weight_decay,
            reuse=reuse,
            scope=scope_i,
        )

        if verbose:
            print(
                (
                    name,
                    "FC params = ",
                    np.prod(layer.W.get_shape().as_list())
                    + np.prod(layer.b.get_shape().as_list()),
                )
            )

        if b_norm:
            name += "_bnorm"
            scope_i = expand_scope_by_name(scope, name)
            layer = batch_normalization(
                layer, decay=b_norm_decay, name=name, reuse=reuse, scope=scope_i
            )
            if verbose:
                print(
                    (
                        "bnorm params = ",
                        np.prod(layer.beta.get_shape().as_list())
                        + np.prod(layer.gamma.get_shape().as_list()),
                    )
                )

        if non_linearity is not None:
            layer = non_linearity(layer)

        if dropout_prob is not None and dropout_prob[i] > 0:
            layer = dropout(layer, 1.0 - dropout_prob[i])

        if verbose:
            print(layer)
            print(("output size:", np.prod(layer.get_shape().as_list()[1:]), "\n"))

    # Last decoding layer never has a non-linearity.
    name = "decoder_fc_" + str(n_layers - 1)
    scope_i = expand_scope_by_name(scope, name)
    layer = fully_connected(
        layer,
        layer_sizes[n_layers - 1],
        activation="linear",
        weights_init="xavier",
        name=name,
        regularizer=regularizer,
        weight_decay=weight_decay,
        reuse=reuse,
        scope=scope_i,
    )
    if verbose:
        print(
            (
                name,
                "FC params = ",
                np.prod(layer.W.get_shape().as_list())
                + np.prod(layer.b.get_shape().as_list()),
            )
        )

    if b_norm_finish:
        name += "_bnorm"
        scope_i = expand_scope_by_name(scope, name)
        layer = batch_normalization(
            layer, decay=b_norm_decay_finish, name=name, reuse=reuse, scope=scope_i
        )
        if verbose:
            print(
                (
                    "bnorm params = ",
                    np.prod(layer.beta.get_shape().as_list())
                    + np.prod(layer.gamma.get_shape().as_list()),
                )
            )

    if verbose:
        print(layer)
        print(("output size:", np.prod(layer.get_shape().as_list()[1:]), "\n"))

    return layer
def decoder_with_fc_only ( latent_signal , layer_sizes = [ ] , b_norm = True , b_norm_decay = 0.9 , non_linearity = tf . nn . relu , regularizer = None , weight_decay = 0.001 , reuse = False , scope = None , dropout_prob = None , b_norm_finish = False , b_norm_decay_finish = 0.9 , verbose = False , ) : if verbose : print ( "Building Decoder" ) n_layers = len ( layer_sizes ) dropout_prob = replicate_parameter_for_all_layers ( dropout_prob , n_layers ) if n_layers < 2 : raise ValueError ( "For an FC decoder with single a layer use simpler code." ) for i in range ( 0 , n_layers - 1 ) : name = "decoder_fc_" + str ( i ) scope_i = expand_scope_by_name ( scope , name ) if i == 0 : layer = latent_signal layer = fully_connected ( layer , layer_sizes [ i ] , activation = "linear" , weights_init = "xavier" , name = name , regularizer = regularizer , weight_decay = weight_decay , reuse = reuse , scope = scope_i , ) if verbose : print ( ( name , "FC params = " , np . prod ( layer . W . get_shape ( ) . as_list ( ) ) + np . prod ( layer . b . get_shape ( ) . as_list ( ) ) , ) ) if b_norm : name += "_bnorm" scope_i = expand_scope_by_name ( scope , name ) layer = batch_normalization ( layer , decay = b_norm_decay , name = name , reuse = reuse , scope = scope_i ) if verbose : print ( ( "bnorm params = " , np . prod ( layer . beta . get_shape ( ) . as_list ( ) ) + np . prod ( layer . gamma . get_shape ( ) . as_list ( ) ) , ) ) if non_linearity is not None : layer = non_linearity ( layer ) if dropout_prob is not None and dropout_prob [ i ] > 0 : layer = dropout ( layer , 1.0 - dropout_prob [ i ] ) if verbose : print ( layer ) print ( ( "output size:" , np . prod ( layer . get_shape ( ) . as_list ( ) [ 1 : ] ) , "\n" ) ) # Last decoding layer never has a non-linearity. name = "decoder_fc_" + str ( n_layers - 1 ) scope_i = expand_scope_by_name ( scope , name ) layer = fully_connected ( layer , layer_sizes [ n_layers - 1 ] , activation = "linear" , weights_init = "xavier" , name = name , regularizer = regularizer , weight_decay = weight_decay , reuse = reuse , scope = scope_i , ) if verbose : print ( ( name , "FC params = " , np . prod ( layer . W . get_shape ( ) . as_list ( ) ) + np . prod ( layer . b . get_shape ( ) . as_list ( ) ) , ) ) if b_norm_finish : name += "_bnorm" scope_i = expand_scope_by_name ( scope , name ) layer = batch_normalization ( layer , decay = b_norm_decay_finish , name = name , reuse = reuse , scope = scope_i ) if verbose : print ( ( "bnorm params = " , np . prod ( layer . beta . get_shape ( ) . as_list ( ) ) + np . prod ( layer . gamma . get_shape ( ) . as_list ( ) ) , ) ) if verbose : print ( layer ) print ( ( "output size:" , np . prod ( layer . get_shape ( ) . as_list ( ) [ 1 : ] ) , "\n" ) ) return layer