Is it possible to update one particular value in hashtable in Tensorflow

Viewed 1528

I would like to have a look-up table for some integers and their corresponding biases. When neuron is activated, I would like to update that 'one' particular value of that particular key which represents an integer in the variable. Is is possible to update that value after one forward and one backward pass?

import tensorflow as tf
table = tf.contrib.lookup.MutableHashTable(key_dtype=tf.int64, value_dtype=tf.float64, default_value=-1)

with tf.Session() as sess:
    keys = tf.constant([1, 2, 3], dtype=tf.int64)
    vals = tf.constant([-0.1, 2.3, 0.4], dtype=tf.float64)

    # Insert values to hash table and run the op.
    insert_op = table.insert(keys, vals)
    sess.run(insert_op)

    # Print hash table lookups.
    print(sess.run(table.lookup(keys)))
0 Answers
Related