1
在我看來,numpy功能bincount
是非常有用和簡單的使用,所以我自然使用TensorFlow中的模擬功能。最近我瞭解到,不幸tf.bincount
不支持GPU(因爲您可以閱讀here)。在TensorFlow 與 GPU中有效嗎?有沒有其他方法可以加權直方圖?Tensorflow:有沒有一種方法來建立一個沒有tf.bincount的加權直方圖?
sess = tf.Session()
values = tf.random_uniform((1,50),10,20,dtype = tf.int32)
weights = tf.random_uniform((1,50),0,1,dtype = tf.float32)
counts = tf.bincount(values, weights = weights)
histogram = sess.run(counts)
print(histogram)