Hub: TF Broken with current nightly 2.0

Created on 23 Aug 2019  路  8Comments  路  Source: tensorflow/hub

Seems like even simple code is failing from tutorial

IMAGE_SHAPE = (224, 224)

classifier = tf.keras.Sequential([
    hub.KerasLayer(classifier_url, input_shape=IMAGE_SHAPE+(3,))
])

Breaks with following error

TypeError: Variable is unhashable if Tensor equality is enabled. Instead, use tensor.experimental_ref() as the key.

My env had following versions

print(tf.__version__)
print(hub.__version__)
2.0.0-dev20190822
0.5.0
hub awaiting tensorflower Keras bug

Most helpful comment

Hi Sergii, thanks for reporting!

We are aware of the issue, it's caused by interactions with TF on equality operators.

While we release a new 0.6.0 version with a fix, you should be able to workaround using
pip install tf-hub-nightly.

All 8 comments

Btw, the same is broken with freshly released 2.0.0-rc0

Please find a colab for reproducibility
https://colab.research.google.com/drive/1N9heYSp8Cf8TmkZx79LaJWKWeIE01BYI

cc @andresusanopinto

Hi Sergii, thanks for reporting!

We are aware of the issue, it's caused by interactions with TF on equality operators.

While we release a new 0.6.0 version with a fix, you should be able to workaround using
pip install tf-hub-nightly.

@vbardiovskyg shall we somehow update current docs and tutorials? since currently they are broken if rc is used?

cc @lamberta @dynamicwebpaige

We've just released 0.6.0, can you please try again?

Which tutorial are you referring to? We've updated the one at https://www.tensorflow.org/hub (not live yet), but maybe there is more?

You are right, tutorials by default do not specify rc0 version for tutorials, so only if a person start using rc0 and runs tutorial it would fail.

Just checked and it works fine. Thank you for timely fix!

TF 2.0 tutorials now work for me also. thank you for fixing!

I'm confused why are we talking about tfp 0.6, we've been working with 0.7 already without problem until the release of TF 2.0.0-rc where this issue started. Is this now only fixed in 0.6 but not in 0.7?

tfd.MultivariateNormalDiag(loc, scale).sample()

/home/pycharm_project/VAE/vae_tf2.py:636 compute_loss *
latent_code = posterior.sample()
/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/distributions/distribution.py:840 sample
return self._call_sample_n(sample_shape, seed, name, *kwargs)
/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/distributions/transformed_distribution.py:391 _call_sample_n
y = self.bijector.forward(x, *
bijector_kwargs)
/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/bijectors/bijector.py:933 forward
return self._call_forward(x, name, **kwargs)
/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/bijectors/bijector.py:904 _call_forward
mapping = self._lookup(x=x, kwargs=kwargs)
/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/bijectors/bijector.py:1343 _lookup
mapping = self._from_x[x].get(subkey, mapping).merge(x=x)
/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/bijectors/bijector.py:151 __getitem__
return super(WeakKeyDefaultDict, self).__getitem__(weak_key)
/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/bijectors/bijector.py:181 __hash__
return hash(x)
/usr/local/lib/python3.5/dist-packages/tensorflow_core/python/framework/ops.py:713 __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.

After downgrading from tfp 0.7 to 0.6 (with TF2.0.0-rc0) import error:

File "/usr/local/lib/python3.5/dist-packages/tensorflow_probability/__init__.py", line 78, in
from tensorflow_probability.python import * # pylint: disable=wildcard-import
File "/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/__init__.py", line 21, in
from tensorflow_probability.python import bijectors
File "/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/bijectors/__init__.py", line 46, in
from tensorflow_probability.python.bijectors.matveclu import MatvecLU
File "/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/bijectors/matveclu.py", line 24, in
from tensorflow_probability.python.math.linalg import lu_reconstruct
File "/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/math/__init__.py", line 22, in
from tensorflow_probability.python.math.diag_jacobian import diag_jacobian
File "/usr/local/lib/python3.5/dist-packages/tensorflow_probability/python/math/diag_jacobian.py", line 24, in
tfe = tf.contrib.eager
AttributeError: module 'tensorflow' has no attribute 'contrib'

Was this page helpful?
0 / 5 - 0 ratings

Related issues

martiansideofthemoon picture martiansideofthemoon  路  3Comments

AlfredAM picture AlfredAM  路  4Comments

codevjs picture codevjs  路  4Comments

bhack picture bhack  路  3Comments

marcoaleixo picture marcoaleixo  路  4Comments