I have a Problem with tensorflow-probability, I want to calculate the variance of my tensor using
tfp.stats.variance(E)
But I am always getting the following error message:
AttributeError: module 'tensorflow_probability' has no attribute 'stats'
I have searched for hours through the internet and the forum, but nothing helped me, so I am asking the question hoping someone can help me. I am using the tensorflow version: 2.13.0.
And I am using python on a MacBook and visual studio code
When I run pip3 list I get the following:
tensorflow 2.13.0
tensorflow-estimator 2.13.0
tensorflow-io-gcs-filesystem 0.33.0
tensorflow-probability 0.20.1
tfp-nightly 0.22.0.dev20230925
Thank you in advance
Best wishes
I have searched for hours through the internet and the forum, but nothing helped me, so I am asking the question hoping someone can help me.
Can you try Installing the latest version of tfp. I tried with updated version in my local and its working good
tensorboard 2.13.0
tensorboard-data-server 0.7.1
tensorflow 2.13.0
tensorflow-estimator 2.13.0
tensorflow-intel 2.13.0
tensorflow-io-gcs-filesystem 0.31.0
tensorflow-probability 0.21.0
Install pip install --user tensorflow
Install tfp pip install --upgrade tensorflow-probability
To keep it simple, I tried the below code
import os
import tensorflow as tf
import tensorflow_probability as tfp
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
E = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0])
variance = tfp.stats.variance(E)
print(variance)
Resulted Output :
tf.Tensor(2.0, shape=(), dtype=float32)
Hope this helps.