Is there a Tensorflow function to initialize all tables [Text classification]

Viewed 209

I’m dealing with an inference model problem in Tensorflow. I’ve loaded it from a SavedModel with a dictionary of custom object (a specific metric). I’ve made an inference model and give it a tensor of raw string, but I receive that error :

FailedPreconditionError: Exception encountered when calling layer "string_lookup" (type StringLookup).

Table not initialized. [Op:LookupTableFindV2]

So I’ve finally initialize tables with this deprecated method (tensorflow 2.7) :

tf.compat.v1.initialize_all_tables(name='init_all_tables')

As you imagine, it does’nt work.

So I have found those tickets on the subjet link1 link2 link3

My question is : Do I need to save my model with a specific command for a legacy init option, before loading it for inference modeling ?

1 Answers

My model didn’t integrate the adapt step of the vectorize_layer inside it. It has been necessary to externalize it.

So, to restore my model and for making inference with it, the solution was simply to reload my model and also readapt the vector_layer on the same train text data, in a moment.

Related