k (i.e., num_components) represents the number of component OneHotCategorical distributions and d (i.e., event_size) represents the number of categories within each OneHotCategorical distribution.

layer_categorical_mixture_of_one_hot_categorical(
  object,
  event_size,
  num_components,
  convert_to_tensor_fn = tfp$distributions$Distribution$sample,
  sample_dtype = NULL,
  validate_args = FALSE,
  ...
)

Arguments

object

Model or layer object

event_size

Scalar integer representing the size of single draw from this distribution.

num_components

Scalar integer representing the number of mixture components. Must be at least 1. (If num_components=1, it's more efficient to use the OneHotCategorical layer.)

convert_to_tensor_fn

A callable that takes a tfd$Distribution instance and returns a tf$Tensor-like object. Default value: tfd$distributions$Distribution$sample.

sample_dtype

dtype of samples produced by this distribution. Default value: NULL (i.e., previous layer's dtype).

validate_args

Logical, default FALSE. When TRUE distribution parameters are checked for validity despite possibly degrading runtime performance. When FALSE invalid inputs may silently render incorrect outputs. Default value: FALSE.

...

Additional arguments passed to args of keras::create_layer.

Value

a Keras layer

Details

Typical choices for convert_to_tensor_fn include:

  • tfp$distributions$Distribution$sample

  • tfp$distributions$Distribution$mean

  • tfp$distributions$Distribution$mode

See also