FailedPreconditionError: Table already initialized

≯℡__Kan透↙ 提交于 2019-12-24 04:21:07

问题


I am reading data from tfrecords with dataset api. I am converting string data to dummy data with following code.

SFR1 = tf.feature_column.indicator_column(
    tf.feature_column.categorical_column_with_vocabulary_list("SFR1 ",
                                                             vocabulary_list=("1", "2")))

But when i run my code, tensorflow is throwing following error.

tensorflow.python.framework.errors_impl.FailedPreconditionError: Table already initialized. [[Node: Generator/input_layer/SFR1 _indicator/SFR1 _lookup/hash_table/table_init = InitializeTableV2[Tkey=DT_STRING, Tval=DT_INT64](Generator/input_layer/SFR1 _indicator/SFR1 _lookup/hash_table, Generator/input_layer/SFR1 _indicator/SFR1 _lookup/Const, Generator/input_layer/SFR1 _indicator/SFR1 _lookup/ToInt64)]] [[Node: Generator2/IteratorGetNext = IteratorGetNextoutput_shapes=[[?,10000,160]], output_types=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

I have tried many combinations to determine the source of problem. I understood that this problem occurs when model includes both tf.feature_column.categorical_column_with_vocabulary_list and dataset api. If i choose TFRecordReader instead of dataset, code is running.

When i search stackoverflow, I noticed that there is a similar issue. I am adding issue link below. As both problem are same, I didn't copy all my code. Below link includes enough data to explain my problem

Tensorflow feature columns in Dataset map Table already initialized issue

Thanks.


回答1:


I came across the same issue. Then modified my code following the warning from Tensorflow and it works:

Creating lookup tables inside a function passed to Dataset.map() is not supported. Create each table outside the function, and capture it inside the function to use it.

Hope it would help.




回答2:


This is issue with earlier version of TensorFlow, updating to TF2.0 should resolve this.

pip install --upgrade tensorflow



来源:https://stackoverflow.com/questions/50412495/failedpreconditionerror-table-already-initialized

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!