Last active
February 12, 2019 17:13
-
-
Save oborchers/b19599862e6ad93a3631640cb92b828d to your computer and use it in GitHub Desktop.
Create the parameter vectors for the MDN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tensorflow.keras.layers import Input, Dense, Concatenate | |
neurons = 500 # Neurons of the DNN hidden layers | |
components = 2 # Number of components in the mixture | |
no_parameters = 3 # Paramters of the mixture (alpha, mu, sigma) | |
inputs = Input(shape=(x_train.shape[1],)) | |
h1 = Dense(neurons, activation="relu")(inputs) | |
h2 = Dense(neurons, activation="relu")(h1) | |
alphas = Dense(components, activation="softmax", name="alphas")(h2) # Create vector for alpha (softmax constrained) | |
mus = Dense(components, name="mus")(h2) # Create vector for mus | |
sigmas = Dense(components, activation="nnelu", name="sigmas")(h2) # Create vector sigmas (nnelu constrained) | |
pvector = Concatenate(name="output")([alphas, mus, sigmas]) # Concatenate (required for model compilation) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment