(
    encoder,
    decoder,
    n_components,
    dims,
    n_data,
    parametric_embedding,
    parametric_reconstruction,
    init_embedding=None,
)
return encoder, decoder
Generates a set of keras networks for the encoder and decoder if one has not already
    been predefined.

    Parameters
    ----------
    encoder : tf.keras.Sequential
        The encoder Keras network
    decoder : tf.keras.Sequential
        the decoder Keras network
    n_components : int
        the dimensionality of the latent space
    dims : tuple of shape (dim1, dim2, dim3...)
        dimensionality of data
    n_data : number of elements in dataset
        # of elements in training dataset
    parametric_embedding : bool
        Whether the embedder is parametric or non-parametric
    parametric_reconstruction : bool
        Whether the decoder is parametric or non-parametric
    init_embedding : array (optional, default None)
        The initial embedding, for nonparametric embeddings

    Returns
    -------
    encoder: tf.keras.Sequential
        encoder keras network
    decoder: tf.keras.Sequential
        decoder keras network
Generates a set of keras networks for the encoder and decoder if one has not already
    been predefined.
Generates a set of keras networks for the encoder and decoder if one has not already been predefined .
def prepare_networks(
    encoder,
    decoder,
    n_components,
    dims,
    n_data,
    parametric_embedding,
    parametric_reconstruction,
    init_embedding=None,
):
    """
    Generates a set of keras networks for the encoder and decoder if one has not already
    been predefined.

    Parameters
    ----------
    encoder : tf.keras.Sequential
        The encoder Keras network
    decoder : tf.keras.Sequential
        the decoder Keras network
    n_components : int
        the dimensionality of the latent space
    dims : tuple of shape (dim1, dim2, dim3...)
        dimensionality of data
    n_data : number of elements in dataset
        # of elements in training dataset
    parametric_embedding : bool
        Whether the embedder is parametric or non-parametric
    parametric_reconstruction : bool
        Whether the decoder is parametric or non-parametric
    init_embedding : array (optional, default None)
        The initial embedding, for nonparametric embeddings

    Returns
    -------
    encoder: tf.keras.Sequential
        encoder keras network
    decoder: tf.keras.Sequential
        decoder keras network
    """

    if parametric_embedding:
        if encoder is None:
            encoder = tf.keras.Sequential(
                [
                    tf.keras.layers.InputLayer(input_shape=dims),
                    tf.keras.layers.Flatten(),
                    tf.keras.layers.Dense(units=100, activation="relu"),
                    tf.keras.layers.Dense(units=100, activation="relu"),
                    tf.keras.layers.Dense(units=100, activation="relu"),
                    tf.keras.layers.Dense(units=n_components, name="z"),
                ]
            )
    else:
        embedding_layer = tf.keras.layers.Embedding(
            n_data, n_components, input_length=1
        )
        embedding_layer.build(input_shape=(1,))
        embedding_layer.set_weights([init_embedding])
        encoder = tf.keras.Sequential([embedding_layer])

    if decoder is None:
        if parametric_reconstruction:
            decoder = tf.keras.Sequential(
                [
                    tf.keras.layers.InputLayer(input_shape=n_components),
                    tf.keras.layers.Dense(units=100, activation="relu"),
                    tf.keras.layers.Dense(units=100, activation="relu"),
                    tf.keras.layers.Dense(units=100, activation="relu"),
                    tf.keras.layers.Dense(
                        units=np.product(dims), name="recon", activation=None
                    ),
                    tf.keras.layers.Reshape(dims),
                ]
            )

    return encoder, decoder
def prepare_networks ( encoder , decoder , n_components , dims , n_data , parametric_embedding , parametric_reconstruction , init_embedding = None , ) : if parametric_embedding : if encoder is None : encoder = tf . keras . Sequential ( [ tf . keras . layers . InputLayer ( input_shape = dims ) , tf . keras . layers . Flatten ( ) , tf . keras . layers . Dense ( units = 100 , activation = "relu" ) , tf . keras . layers . Dense ( units = 100 , activation = "relu" ) , tf . keras . layers . Dense ( units = 100 , activation = "relu" ) , tf . keras . layers . Dense ( units = n_components , name = "z" ) , ] ) else : embedding_layer = tf . keras . layers . Embedding ( n_data , n_components , input_length = 1 ) embedding_layer . build ( input_shape = ( 1 , ) ) embedding_layer . set_weights ( [ init_embedding ] ) encoder = tf . keras . Sequential ( [ embedding_layer ] ) if decoder is None : if parametric_reconstruction : decoder = tf . keras . Sequential ( [ tf . keras . layers . InputLayer ( input_shape = n_components ) , tf . keras . layers . Dense ( units = 100 , activation = "relu" ) , tf . keras . layers . Dense ( units = 100 , activation = "relu" ) , tf . keras . layers . Dense ( units = 100 , activation = "relu" ) , tf . keras . layers . Dense ( units = np . product ( dims ) , name = "recon" , activation = None ) , tf . keras . layers . Reshape ( dims ) , ] ) return encoder , decoder