How to use a tensor as a key of dictionary in Tensorflow?

Viewed 145

I want to use the value of a tensor as key of a dictionary, which means same mapping for tensors of same value. You can check the following codes for details.

import tensorflow as tf

dic = {}
a = tf.constant(0)
dic[a.ref()] = 1
b = tf.constant(0)
tf.print(dic[b.ref()])

The tensors a and b are created with same value, but have different keys in dictionary. How to implement the same key for tensors of same value?

0 Answers
Related