2024-05-16 21:03:30 发布
网友
import tensorflow as tf a = tf.zeros([10]) b = tf.zeros([10]) state = tf.tuple([a, b], name='initial_state') with tf.Session() as sess: s = sess.run('initial_state:0')
在这个例子中,我得到以下错误:
当我传递张量时,它起作用,但当我传递名字时就不行了。 为什么我不能把名字传给你?在
@E逯net4 will behave的答案很好。但首先,你应该知道怎么做tf.元组工作。 就像在tf.元组文件上说
tf.tuple( tensors, control_inputs=None, name=None )
You have to sometime follow the instruction. But it hard to understand there as no example shown so see mine :
这里ops = tf.tuple([tensor1,tensor2,...],control_inputs=c_ops)
ops = tf.tuple([tensor1,tensor2,...],control_inputs=c_ops)
输出显示:
[array([11], dtype=int32), array([30], dtype=int32), array([0.83333333])]`
TensorFlow中的元组不是张量,而是张量的列表,因此不能通过图中的操作作为一个整体获取。tf.tuple将创建一些分组和依赖关系控制操作(initial_state/group_deps,initial_state/control_dependency和{}),但仅此而已。在
tf.tuple
initial_state/group_deps
initial_state/control_dependency
由于state是一个列表,因此它是Session#run的有效fetches参数。还可以从每个元组元素构建一个操作名列表,并使用该列表。在
state
Session#run
fetches
s = sess.run(['zeros:0', 'zeros_1:0']) # [ # array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], dtype=float32), # array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], dtype=float32) # ]
@E逯net4 will behave的答案很好。但首先,你应该知道怎么做tf.元组工作。 就像在tf.元组文件上说
^{pr2}$这里
ops = tf.tuple([tensor1,tensor2,...],control_inputs=c_ops)
输出显示:
TensorFlow中的元组不是张量,而是张量的列表,因此不能通过图中的操作作为一个整体获取。}),但仅此而已。在
tf.tuple
将创建一些分组和依赖关系控制操作(initial_state/group_deps
,initial_state/control_dependency
和{由于
state
是一个列表,因此它是Session#run
的有效fetches
参数。还可以从每个元组元素构建一个操作名列表,并使用该列表。在相关问题 更多 >
编程相关推荐