2

I am using python 3 with tensorflow 1.12 & eager eval

I am trying to use scatter update as explained here

I am getting the following error:

AttributeError: 'EagerTensor' object has no attribute '_lazy_read'

Is there a workaround or another function that is available for eager eval?

Amir
  • 16,067
  • 10
  • 80
  • 119
thebeancounter
  • 4,261
  • 8
  • 61
  • 109

1 Answers1

2

scatter_update needs Variable not constant tensor:

Applies sparse updates to a variable reference.

I guess you passed a constant tensor to scater_update that caused throw an exception. Here is an example in eager-mode:

import tensorflow as tf

tf.enable_eager_execution()

data = tf.Variable([[2],
                    [3],
                    [4],
                    [5],
                    [6]])

cond = tf.where(tf.less(data, 5)) # update value less than 5
match_data = tf.gather_nd(data, cond)
square_data = tf.square(match_data) # square value less than 5

data = tf.scatter_nd_update(data, cond, square_data)

print(data)

# array([[ 4],
#    [ 9],
#    [16],
#    [ 5],
#    [ 6]], dtype=int32)>
Amir
  • 16,067
  • 10
  • 80
  • 119