gpt4 book ai didi

python - 属性错误: object has no attribute '_lazy_read'

转载 作者:行者123 更新时间:2023-11-30 09:44:23 25 4
gpt4 key购买 nike

我正在使用 python 3 和tensorflow 1.12 & eager eval

我正在尝试按照说明使用分散更新 here

我收到以下错误:

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

是否有解决方法或其他可用于急切评估的函数?

最佳答案

scatter_update需要变量而不是常数张量:

Applies sparse updates to a variable reference.

我猜你将一个常量张量传递给了scater_update,导致抛出异常。以下是 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)>

关于python - 属性错误: object has no attribute '_lazy_read' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54399670/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com