tensorflow: TF 2.0.0-rc0 + TFP 0.7 broken combo: Tensor is unhashable if Tensor equality is enabled. Instead, use tensor.experimental_ref() as the key
Error occurs: tf-gpu 2.0.0-rc0 with tfp 0.7
Code to reproduce:
import tensorflow_probability as tfp
tfp.distributions.MultivariateNormalDiag([0.], [1.]).sample()
Error returned:
Traceback (most recent call last): File “/home/pycharm_project/VAE/save_issue_reproduction.py”, line 3, in <module> tfp.distributions.MultivariateNormalDiag([0.], [1.]).sample() File “/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/distributions/distribution.py”, line 840, in sample return self._call_sample_n(sample_shape, seed, name, **kwargs) File “/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/distributions/transformed_distribution.py”, line 391, in _call_sample_n y = self.bijector.forward(x, **bijector_kwargs) File “/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/bijectors/bijector.py”, line 933, in forward return self._call_forward(x, name, **kwargs) File “/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/bijectors/bijector.py”, line 904, in _call_forward mapping = self._lookup(x=x, kwargs=kwargs) File “/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/bijectors/bijector.py”, line 1343, in _lookup mapping = self._from_x[x].get(subkey, mapping).merge(x=x) File “/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/bijectors/bijector.py”, line 151, in getitem return super(WeakKeyDefaultDict, self).getitem(weak_key) File “/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/bijectors/bijector.py”, line 181, in hash return hash(x) File “/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/framework/ops.py”, line 713, in hash raise TypeError("Tensor is unhashable if Tensor equality is enabled. " TypeError: Tensor is unhashable if Tensor equality is enabled. Instead, use tensor.experimental_ref() as the key.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 20 (2 by maintainers)
After upgrade
Error still happens
My environment:
Piece of code causes error
pip install tf-hub-nightly it works
Thanks for the report! This is due to a change in TF’s Tensor equality semantics that occurred between the TFP 0.7 release and the TF 2.0.0-rc0 prerelease. You can fix it by installing TFP 0.8-rc0 (
pip install tensorflow_probability==0.8.0rc0 --user --upgrade), which should include the necessary updates.