TensorFlow - Natural Language Processing With RNNs: Making Predictions 'keras.preprocessing' has no attribute 'text'

Tell us what’s happening:

Getting the following error trying to run the notebook:
https://colab.research.google.com/drive/1ysEKrw_LE2jMndo1snrZUh5w87LQsCxk

----> 4   tokens = keras.preprocessing.text.text_to_word_sequence(text)
      5   tokens = [word_index[word] if word in word_index else 0 for word in tokens]
      6   return sequence.pad_sequences([tokens], MAXLEN)[0]

AttributeError: module 'keras.preprocessing' has no attribute 'text'

Most of the info I could find is saying that these modules and functions are deprecated, and they are posts from 4 years ago or longer.

I tried downgrading keras from 3.4.1 to 2.2.0 but that broke other imports.

Any advice appreciated, otherwise I’ll just continue with the video and skip trying to make this notebook work.

Challenge Information:

TensorFlow - Natural Language Processing With RNNs: Making Predictions

that match with the age of the notebooks, so maybe there is no way to make them work?
it’s in program to update this part of the curriculum too, but the earlier parts have precedence

1 Like

This is what I was thinking, the notebooks are old and this course will likely need to be updated soon anyways.

I won’t want to spend more time troubleshooting but I thought I would make a note here in case anyone else has the same problem.

Thanks!