Learn R Programming

reservr (version 0.0.2)

as_params: Convert TensorFlow tensors to distribution parameters recursively

Description

Convert TensorFlow tensors to distribution parameters recursively

Usage

as_params(x)

Value

A nested list of vectors suitable as distribution parameters

Arguments

x

possibly nested list structure of tensorflow.tensors

Examples

Run this code
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)
}

Run the code above in your browser using DataLab