Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix layer.add_variable being deprecated #1703

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tensorflow_probability/python/layers/conv_variational.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,28 +185,28 @@ def build(self, input_shape):
# Must have a posterior kernel.
self.kernel_posterior = self.kernel_posterior_fn(
dtype, kernel_shape, 'kernel_posterior',
self.trainable, self.add_variable)
self.trainable, self.add_weight)

if self.kernel_prior_fn is None:
self.kernel_prior = None
else:
self.kernel_prior = self.kernel_prior_fn(
dtype, kernel_shape, 'kernel_prior',
self.trainable, self.add_variable)
self.trainable, self.add_weight)

if self.bias_posterior_fn is None:
self.bias_posterior = None
else:
self.bias_posterior = self.bias_posterior_fn(
dtype, (self.filters,), 'bias_posterior',
self.trainable, self.add_variable)
self.trainable, self.add_weight)

if self.bias_prior_fn is None:
self.bias_prior = None
else:
self.bias_prior = self.bias_prior_fn(
dtype, (self.filters,), 'bias_prior',
self.trainable, self.add_variable)
self.trainable, self.add_weight)

self.input_spec = tf.keras.layers.InputSpec(
ndim=self.rank + 2, axes={channel_axis: input_dim})
Expand Down
8 changes: 4 additions & 4 deletions tensorflow_probability/python/layers/dense_variational.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,28 +140,28 @@ def build(self, input_shape):
# Must have a posterior kernel.
self.kernel_posterior = self.kernel_posterior_fn(
dtype, [in_size, self.units], 'kernel_posterior',
self.trainable, self.add_variable)
self.trainable, self.add_weight)

if self.kernel_prior_fn is None:
self.kernel_prior = None
else:
self.kernel_prior = self.kernel_prior_fn(
dtype, [in_size, self.units], 'kernel_prior',
self.trainable, self.add_variable)
self.trainable, self.add_weight)

if self.bias_posterior_fn is None:
self.bias_posterior = None
else:
self.bias_posterior = self.bias_posterior_fn(
dtype, [self.units], 'bias_posterior',
self.trainable, self.add_variable)
self.trainable, self.add_weight)

if self.bias_prior_fn is None:
self.bias_prior = None
else:
self.bias_prior = self.bias_prior_fn(
dtype, [self.units], 'bias_prior',
self.trainable, self.add_variable)
self.trainable, self.add_weight)

self.built = True

Expand Down