0

Let us say that I have a rank-2 tensor (a matrix). I want fill the last row of this pre-existing matrix with zeros. I would not like tensorflow to copy the whole matrix in a new place, because it is huge. Is it possible to do?

Terminus
  • 925
  • 10
  • 23
  • 1
    Does this answer your question? http://stackoverflow.com/questions/39157723/how-to-do-slice-assignment-in-tensorflow – David Parks May 15 '17 at 22:52

1 Answers1

0

The answer is based on David Parks' suggestion to look into this thread: How to do slice assignment in Tensorflow

Using this answer I have arrived at the exact solution to my problem:

a = tf.Variable(tf.ones([10, 36, 36]))   
value = tf.zeros([36, 36])   
d = tf.scatter_update(a, 9 , value)

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    print a.eval(session=sess)
    sess.run(d)
    print a.eval(session=sess)
Community
  • 1
  • 1
Terminus
  • 925
  • 10
  • 23