as_params {reservr} | R Documentation |
Convert TensorFlow tensors to distribution parameters recursively
as_params(x)
x |
possibly nested list structure of |
A nested list of vectors suitable as distribution parameters
if (interactive() && keras::is_keras_available()) {
tf_params <- list(
probs = k_matrix(t(c(0.5, 0.3, 0.2))),
shapes = k_matrix(t(c(1L, 2L, 3L)), dtype = "int32"),
scale = keras::k_constant(1.0)
)
params <- as_params(tf_params)
dist <- dist_erlangmix(vector("list", 3L))
dist$sample(10L, with_params = params)
}