Custom posterior in DenseFlipout layer

I am trying to create a DenseFlipout layer with a GeneralizedNormal distribution for the kernel and Laplace distribution for the biases.

What should the kernel_posterior_fn and bias_posterior_fn in the arguments be?

I know in the DenseVariational case, a function that takes in kernel_size, bias_size, dtype would work. But now the bias_posterior_fn requires dtype, shape, name, trainable, add_variable_fn.

I do not know what to pass in for the add_variable_fn and how this function works.

Any suggestions would be greatly appreciated.

1 Like

Hi @isomorphicdude ,

To create a DenseFlipout layer with GeneralizedNormal and Laplace distributions, define kernel_posterior_fn and bias_posterior_fn using the appropriate distributions. The add_variable_fn is used to create variables for the distributions. Pass these functions to the DenseFlipout layer to create the desired layer.

I have Replicated And created a gist for your reference .

Hope this helps ,

Thank You .