Tensorflow StringLookup layer problem type

Viewed 21

I have the following dataset:

id | col1 | col2 |   col3   | ....
0  |  10  |    20|   [a]    | 
1  |  20  |    30|  [b,k]   |
2  |  30  |    40|  [c,h,k  |
3  |  40  |    50|  [d,t]   |
....

And i'm trying to creat a model this way:

model = tf.keras.Sequential([
    tf.keras.Input(shape=(4, )),
    tf.keras.layers.StringLookup(max_tokens=len(col3.unique()) + 1).adapt(tf.ragged.constant(df.col3)),
    tf.keras.layers.Dense(3, activation=tf.keras.layers.LeakyReLU(alpha=0.001)),
    tf.keras.layers.Dense(2, activation='softmax')
])

But I'm getting this error:

TypeError: The added layer must be an instance of class Layer. Received: layer=None of type <class 'NoneType'>.

Explaining: I want to embed a text column with different lengths in each row. Do i need to create a vocabulary apart? Do I need to separate em 2 sequential models?

0 Answers
Related