でdataset.mapのための互換性のないタイプ()tf.contrib.Dataset.map()
と、ハッシュテーブルルックアップを使用している場合、それは次のエラーで失敗します。再現するTensorflow: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])
コード:
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))
約tf.string_ref
とtf.string
は互換性がありません。
tf.string_ref
であり、tf.string
ではないと奇妙です。なぜこれが事実であり、私はそれについて何ができるのか誰にも分かりますか?
table_ref
はtf.string_ref
hereに関連しています。