Skip to content
Advertisement

a bug for tf.keras.layers.TextVectorization when built from saved configs and weights

I have tried writing a python program to save tf.keras.layers.TextVectorization to disk and load it with the answer of How to save TextVectorization to disk in tensorflow?. The TextVectorization layer built from saved configs outputs a vector with wrong length when the arg output_sequence_length is not None and output_mode='int'. For example, if I set output_sequence_length= 10, and output_mode='int', it is expected that given a text, TextVectorization should output a vector with length of 10, see vectorizer and new_v2 in the code below. However, if TextVectorization’s arg output_mode='int' is set from saved configs, it doesn’t output a vector with length of 10(actually it is 9, the real length of the sentence. It seems like output_sequence_length is not set successfully). See the object new_v1 in the code below. The interesting thing is, I have compared from_disk['config']['output_mode'] and 'int', they equal to each other.

JavaScript

Here are the print() outputs:

JavaScript

Does anyone know why?

Advertisement

Answer

the bug is fixed by the PR in https://github.com/keras-team/keras/pull/15422

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement