-3
import tensorflow as tf
a=tf.int32
b=tf.constant(3)
a==b
給出的而不是給 '假'Tensorflow比較tf.int32和tf.constant給出錯誤
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/framework/dtypes.py", line 248, in __eq__
and self._type_enum == as_dtype(other).as_datatype_enum)
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/framework/dtypes.py", line 536, in as_dtype
if key == type_value:
TypeError: data type not understood
爲什麼這個產生錯誤的錯誤。我正在使用張量流0.8 不應該能夠檢查相等的b/w任何變量。
我是想實現在檢查對象是否存在於列表
a=tf.int32
b=[tf.constant(3),..other objects]
if a in b:
do_something()
我試圖檢查一個對象是否出現在列表中。 (對於我在列表中)如果我是tf.int32和列表包含tf.constant(3)由於這種相等性檢查,我得到一個錯誤。任何想法我可以如何完成這 – Himaprasoon
因爲這可能會幫助其他人,我建議你爲你的實際問題開一個新的問題。你可以在這裏添加評論,所以我可以找到新的問題。如果這個答案對你有幫助,請考慮接受它。 – Dave
我真的需要檢查該對象是否存在於該列表中。所以我迭代並檢查項目'是'tf.int32而不是== – Himaprasoon