【发布时间】:2022-01-10 07:42:10
【问题描述】:
看看下面的代码示例:
def myFun(my_tensor):
#The following line works
my_tensor= tf.tensor_scatter_update(my_tensor, tf.constant([[0]]), tf.constant([1]))
#The following line leads to error
p = tf.cond(tf.math.equal(0, 0), lambda: 1, lambda: 1)
my_tensor= tf.tensor_scatter_update(my_tensor, tf.constant([[p]]), tf.constant([1]))
我用一个简单的案例来描述我面临的问题 此函数(myFun)被称为 tf.while_loop 的主体(如果相关) my_tensor的定义
my_tensor = tf.zeros(5, tf.int32)
如何定义 tf.tensor_scatter_update 的 indices 参数? 我正在使用 tensorflow1.15
【问题讨论】:
标签: python tensorflow tensorflow1.15