Wenn eine Hash-Lookup-Tabelle mit tf.contrib.Dataset.map()
verwenden, schlägt es mit dem folgenden Fehler:Tensorflow: Inkompatible Typen für dataset.map() in tf.contrib.data
TypeError: In op 'hash_table_Lookup', input types ([tf.string, tf.string, tf.int32]) are not compatible with expected types ([tf.string_ref, tf.string, tf.int32])
-Code zu reproduzieren:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
initializer = tf.contrib.lookup.KeyValueTensorInitializer(
['one', 'two', 'three'], [1, 2, 3])
hash_table = tf.contrib.lookup.HashTable(initializer, -1)
tensor = tf.convert_to_tensor(['one', 'two', 'three'])
dataset = tf.contrib.data.Dataset.from_tensor_slices(tensor)
dataset = dataset.map(lambda k: hash_table.lookup(k))
Es klagt über und tf.string
ist inkompatibel.
Es ist seltsam, dass es eine tf.string_ref
und nicht eine tf.string
erwartet. Weiß jemand, warum das so ist und was ich dagegen tun kann?
Die Probleme beziehen sich auf table_ref
wird tf.string_ref
here.