Open Suryansh-patidar opened 5 months ago
Hi @Suryansh-patidar-
Could you please share posterior_mean_field,prior_trainable and train_size to reproduce the issue ?
Hi @Suryansh-patidar-
Could you please share posterior_mean_field,prior_trainable and train_size to reproduce the issue ?
def posterior_mean_field(kernel_size,bias_size,dtype: any):
n = kernel_size + bias_size
c = np.log(np.expm1(1.))
return tf.keras.Sequential([
tfp.layers.VariableLayer(2*n, dtype=dtype),
tfp.layers.DistributionLambda(lambda t: tfd.Independent(
tfd.Normal(loc=t[..., :n],
scale = 1e-5 + tf.nn.softplus(c + t[..., n:])),
reinterpreted_batch_ndims=1)),
])
def prior_trainable(kernel_size,bias_size,dtype: any):
n = kernel_size + bias_size
return tf.keras.Sequential([
tfp.layers.VariableLayer(n, dtype=dtype),
tfp.layers.DistributionLambda(lambda t: tfd.Independent(
tfd.Normal(loc=t,scale=1),
reinterpreted_batch_ndims = 1)),
])
And train_size = 98455
Hi @Suryansh-patidar -
Thanks for the code snippet. I tested the code snippet with keras 2.15 and tensorflow 2.15 and it is working fine. Attached gist for your reference.
This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.
Use:
version_fn = getattr(tf.keras, "version", None)
if version_fn and version_fn().startswith("3."):
import tf_keras as keras
else:
keras = tf.keras
While implementing BNN using tensorflow, i'm getting the below error while using DenseVariational and not sure how to resolve it I have also tried using Google collab/ Jupyter notebook/ VS code/ Kaggle, but the issue is the same The tensorflow version that i tried to use are both 2.15.0/ 2.16.1 and python version is 3.11.3