Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12141

Error when using keras: module 'keras.layers' has no attribute 'TextVectorization'

$
0
0
import osos.environ["KERAS_BACKEND"] = "tensorflow"import pandas as pdimport pathlibimport randomimport stringimport reimport numpy as npimport tensorflow as tfimport kerasfrom keras import layersMAX_SEQUENCE_LENGTH = 40INP_VOCAB_SIZE = 15000input_vectorization = keras.layers.TextVectorization(    max_tokens=INP_VOCAB_SIZE,    output_mode="int",    output_sequence_length=MAX_SEQUENCE_LENGTH)AttributeError: module 'keras.layers' has no attribute 'TextVectorization'

I import the keras module and get layers from keras, but when I try to use keras.layers.TextVectorization, my code throws that error.

I've tried writing the call differently but then I get a new AttributeError.

input_vectorization = tf.keras.TextVectorization(    #same inside as before)AttributeError: module 'keras' has no attribute '__version__'

I've also tried reinstalling both tensorflow and keras using pip, but that didn't change anything. What should I do?


Viewing all articles
Browse latest Browse all 12141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>