Trainable priors in tensorflow-probability

394 views Asked by At

Default Conv2DFlipout layer looks like this

tfp.layers.Convolution2DFlipout(
    filters, kernel_size, strides=(1, 1), padding='valid',
    data_format='channels_last', dilation_rate=(1, 1), activation=None,
    activity_regularizer=None,
    kernel_posterior_fn=tfp_layers_util.default_mean_field_normal_fn(),
    kernel_posterior_tensor_fn=(lambda d: d.sample()),
    kernel_prior_fn=tfp.layers.default_multivariate_normal_fn,
    kernel_divergence_fn=(lambda q, p, ignore: kl_lib.kl_divergence(q, p)), bias_pos
    terior_fn=tfp_layers_util.default_mean_field_normal_fn(is_singular=True),
    bias_posterior_tensor_fn=(lambda d: d.sample()), bias_prior_fn=None,
    bias_divergence_fn=(lambda q, p, ignore: kl_lib.kl_divergence(q, p)), seed=None,
    **kwargs
)

Can someone tell how can I involve kernel and bias priors in training. Also the default multivariate_normal_fn looks like this,

tfp.layers.default_multivariate_normal_fn(dtype, shape, name, trainable, add_variable_fn)

It has trainable as one of the boolean argument, if I set it True, it throws following error.

tfp.layers.Convolution2DFlipout(
    kernel_prior_fn = tfp_layers_util.default_multivariate_normal_fn(trainable=True)
)


TypeError: default_multivariate_normal_fn() missing 4 required positional arguments: 'dtype', 'shape', 'name', and 'add_variable_fn'

Can someone help me solve the issue?

0

There are 0 answers