I am building a model using Keras and Tensorflow probability that should output the parameters of a Gamma function (alpha and beta) instead of a single parameter as shown in the example below (t
is passed to a Normal
distribution function).
import tensorflow as tf
import tensorflow_probability as tfp
tfd = tfp.distributions
# Build model.
model = tf.keras.Sequential([
tf.keras.layers.Dense(1),
tfp.layers.DistributionLambda(lambda t: tfd.Normal(loc=t, scale=1)),
])
# Do inference.
model.compile(optimizer=tf.optimizers.Adam(learning_rate=0.05), loss=negloglik)
model.fit(x, y, epochs=500, verbose=False)
# Make predictions.
yhat = model(x_tst)
Instead of this I would like to output alpha
and beta
from two Dense
layers and then pass this parameters to a Gamma
distribution function.