fchollet / deep-learning-with-python-notebooks

Jupyter notebooks for the code samples of the book "Deep Learning with Python"
MIT License
18.61k stars 8.63k forks source link

issue with Colab (second edition) chapter 11 part 1 #170

Closed randomgambit closed 3 years ago

randomgambit commented 3 years ago

Hi @fchollet, thanks for this amazing book (and the corresponding colab notebooks).

I tried to run this file https://colab.research.google.com/github/fchollet/deep-learning-with-python-notebooks/blob/master/chapter11_part01_introduction.ipynb#scrollTo=xdw1FYamgsP9

But I am getting the following error

from tensorflow.keras.layers import TextVectorization
text_vectorization = TextVectorization(
    output_mode="int",
)
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-0642862b90e9> in <module>()
----> 1 from tensorflow.keras.layers import TextVectorization
      2 text_vectorization = TextVectorization(
      3     output_mode="int",
      4 )

ImportError: cannot import name 'TextVectorization' from 'tensorflow.keras.layers' (/usr/local/lib/python3.7/dist-packages/tensorflow/keras/layers/__init__.py)

Do you know what the issue is? Thanks!

fchollet commented 3 years ago

Hi, the notebook is meant to be run with TF 2.6 (the new version, still in RC right now). The Colab default at this time is 2.5 (it will switch in a few weeks). With 2.5 you should import TextVectorization from tensorflow.keras.layers.experimental.preprocessing instead.

randomgambit commented 3 years ago

thanks @fchollet ! but is there a way to load tensorflow 2.6 directly instead?