I can successfully run the Keras mnist example. I now would like to run the "English-to-Spanish translation with a sequence-to-sequence Transformer" example found here. I'm running TensorFlow 2.5.0 https://colab.research.google.com/github/keras-team/keras-io/blob/master/examples/nlp/ipynb/neural_machine_translation_with_transformer.ipynb#scrollTo=HPyHRZvOO1G1
When I try to import TextVectorization I get the following error:
>>> import pathlib
>>> import random
>>> import string
>>> import re
>>> import numpy as np
>>> import tensorflow as tf
2021-09-01 11:45:11.253159: I tensorflow/stream_executor/platform/default/dso_loader.cc:53]
Successfully opened dynamic library libcudart.so.11.0
>>> from tensorflow import keras
>>> from tensorflow.keras import layers
>>> from tensorflow.keras.layers import TextVectorization
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'TextVectorization' from 'tensorflow.keras.layers'
(/home/users/stren/anaconda3/lib/python3.8/site-packages/tensorflow/keras/layers/__init__.py)
>>> tf.__version__
'2.5.0'
Any ideas what I'm doing wrong?
I faced the same issue with conda.
The solution can be found here
you should import
TextVectorizationfromtensorflow.keras.layers.experimental.preprocessinginstead
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With